Re: for loop exclusion
- From: spcecdt@xxxxxxxxxx (John DuBois)
- Date: Thu, 27 Apr 2006 19:32:11 -0000
In article <20060426201134.GA11552@xxxxxxxxxxxxxxxxxxx>,
Jeff Hyman <scolist@xxxxxxxxxx> wrote:
Hello all,
# for STRING in "jeff " <== Nope.
for STRING in jeff
do
grep -i $STRING ascii_file
done
In the above example,
how would one exclude "jeffrey" from being found
since I'm only looking for "jeff" ?
If you were just wondering why the above commented-out line didn't work, it's
because you didn't quote $STRING, and so lost the trailing space.
grep -i "$STRING" ascii_file
would not find jeffrey. But, it also wouldn't find "jeff" at the end of a
line. To search for 'jeff' as a word:
egrep -i '(^|[^[:alnum:]])jeff([^[:alnum:]]|$)'
This finds 'jeff' surrounded by non-alphanums or the ends of a line, equivalent
to the word-boundary operators available in some regular expression lexicons.
John
--
John DuBois spcecdt@xxxxxxxxxx KC6QKZ/AE http://www.armory.com/~spcecdt/
.
- References:
- USB printing
- From: Rob S
- Re: USB printing
- From: jboland
- for loop exclusion
- From: Jeff Hyman
- USB printing
- Prev by Date: mysql binaries on new osr6 cd1
- Next by Date: Re: OSR6 Processor confusion - P4 Xeon Extreme Hyper non-sense.
- Previous by thread: Re: for loop exclusion
- Next by thread: Re: USB printing
- Index(es):
Relevant Pages
|