Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #199436

Re: sometimes i go huh (grep result)

From <tomas@tuxteam.de>
Newsgroups linux.debian.user
Subject Re: sometimes i go huh (grep result)
Date 2018-08-27 17:40 +0200
Message-ID <wrrMt-8ko-11@gated-at.bofh.it> (permalink)
References <wrrt7-8e8-9@gated-at.bofh.it> <wrrt7-8e8-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


-----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-----

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: sometimes i go huh (grep result) Greg Wooledge <wooledg@eeg.ccf.org> - 2018-08-27 17:20 +0200
  Re: sometimes i go huh (grep result) <tomas@tuxteam.de> - 2018-08-27 17:40 +0200
  Re: sometimes i go huh (grep result) songbird <songbird@anthive.com> - 2018-08-28 04:40 +0200

csiph-web