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


Groups > linux.debian.user > #199428 > unrolled thread

Re: sometimes i go huh (grep result)

Started byGreg Wooledge <wooledg@eeg.ccf.org>
First post2018-08-27 17:20 +0200
Last post2018-08-28 04:40 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.debian.user

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  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

#199428 — Re: sometimes i go huh (grep result)

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2018-08-27 17:20 +0200
SubjectRe: sometimes i go huh (grep result)
Message-ID<wrrt7-8e8-7@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#199436

From<tomas@tuxteam.de>
Date2018-08-27 17:40 +0200
Message-ID<wrrMt-8ko-11@gated-at.bofh.it>
In reply to#199428
-----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-----

[toc] | [prev] | [next] | [standalone]


#199467

Fromsongbird <songbird@anthive.com>
Date2018-08-28 04:40 +0200
Message-ID<wrC5b-61s-7@gated-at.bofh.it>
In reply to#199428
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

  i just found it interesting that after this many years
of linux/unix i'd not remembered this issue.  my golden
years are ahead a bit yet so i sure hope this isn't a
mental issue!  lol


  songbird

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web