grep problem

Vladimir Botka vbotka at gmail.com
Thu Dec 7 01:49:19 UTC 2017


> > $ echo 'a-b' | grep  '\-b'
> > a-b  

> Looks like it's treated as option -b even inside the single quotes, you 
> could use '--' to mark the end of options, i.e.:
> $ echo 'a-b' | grep -- -b
> a-b

FWIW. Still the question remains what makes escaped -b a pattern. It'd
be necessary to learn about getopt_long which is used to parse the
arguments to understand it, I think.
https://www.gnu.org/software/libc/manual/html_node/Getopt-Long-Options.html

	-vlado
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20171207/c05f9d76/attachment.sig>


More information about the freebsd-questions mailing list