GNU bug report logs -
#38792
man grep
Previous Next
Reported by: Martin Simons <martin <at> webhuis.nl>
Date: Sun, 29 Dec 2019 15:19:01 UTC
Severity: normal
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):
2019-12-29 15:24:47 +0100, Martin Simons:
[...]
> martin <at> laptop:~/test$ grep 'Jantje*' school.txt
> Which delivers the desired output:
> Jantje
It also matches on Jantj? The * regexp operator matches 0 or
more of the preceding atom. So e* matches 0 or more "e"s. It's
not to confused with the "*" shell wildcard operator.
In effect, that's equivalent to
grep Jantj school.txt
[...]
> martin <at> laptop:~/test$ grep Jantje* school.txt
> Delivering this undesired output:
> Jantjes:Jantje zag eens pruimen hangen
> Jantjes:en Jantje wilde pruimen plukken voor zijn moeder
> Jantjes:toen zei Jantjes moeder
> Jantjes:pas toch op Jantje!
> school.txt:Jantje
> school.txt:Ik las dat Jantje
> school.txt:Jantje voortaan op tijd op school komt,
> school.txt:Hoogachtend, Jantjes vader, Piet Bel.
>
> In trying to give more weight to the argument I pointed the students to the
> man page of grep, but it struck me that there is not a single reference to
> the need of using quotes in the search pattern. This does not help.
All grep receives is a list of arguments. That * needs to be
quoted for the shell not to treat it as a glob operator, not for
grep.
You'll find explanation of shell globbing (aka filename
generation, aka pathname expansion, aka filename expansion) and
the effect of quoting on it in your shell manual.
For the GNU shell, that's with:
info bash 'filename expansion'
What needs to be quoted for a given shell varies with the shell
implementation, grep has nothing to do with that.
--
Stephane
This bug report was last modified 4 years and 238 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.