Web lists-archives.com

Re: sometimes i go huh (grep result)




-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Aug 27, 2018 at 11:19:25AM -0400, Greg Wooledge wrote:
> On Mon, Aug 27, 2018 at 10:36:12AM -0400, songbird wrote:
> > me@ant(25)$ env | grep -F "-g"
> > grep: invalid option -- 'g'
> 
> You want either -- or -e.
> 
> grep -F -- -g
> grep -F -e -g

More generally, '--' is convention for "end of option arguments,
normal arguments from here on". Most utilities nowadays stick to
that convention. It was introduced precisely for this case.

Note that quoting, as you do (i.e. "-g") can't work, because the
shell unwraps that level of quotes; grep will still see -g and
think it's an option. This quoting will help to "protect" whitespace:

  grep foo bar

will see two arguments, foo and bar, whereas

  grep "foo bar"

will see one, "foo bar".

Cheers
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAluEGYYACgkQBcgs9XrR2kb6vACfSGHIgX57p5r3oyJ+5vNFQgCX
sVUAn13XlvIHlRGYmzNeLfEpDwaDDFQx
=vMte
-----END PGP SIGNATURE-----