Article View: comp.sys.amiga.tech
Article #4408Re: grep-ing for "*" with SKsh
From: Steve Koren
Date: Tue, 17 Jul 1990 13:21
Date: Tue, 17 Jul 1990 13:21
31 lines
1824 bytes
1824 bytes
> With SKsh 1.3 I used to be able to issue the command: grep "*" s:crontab
> to pull out all lines with a "*" character. Now I get a "grep: invalid
I doubt you were doing that with 1.3, since there was no grep command
in SKsh 1.3. Perhaps you were using the 1.3 SKsh binary with the
1.4 external commands?
At any rate, there are two ways to do this. The first (and probably
best) is to use fgrep. Fgrep searches for strings only and not
regular expressions as grep does. Hence, the '*' is not a special
character to fgrep and it will search for it as you would expect.
In addition, fgrep is about 3 times as fast and smaller. Note that
you must still escape this character since it is a valid shell
wildcard character. Something like this should work:
fgrep '*' myfiles
or
fgrep \* myfiles
The problem with using "grep" to search for the '*' is that the '*'
is a "special" regular expression character meaning "0 or more of the
previous expression". It is also a special character to the shell,
used in pattern matching. You must escape both of these to use the
'*' with grep. Fgrep is easier. If you normally find yourself
using fgrep instead of grep, you can alias one to the other.
The SKsh manual entry for "grep" does not explain regular expressions.
Should I put it in there? Perhaps it would be of help to people
not familar with them.
- steve
Technical Details
Message-ID:
<13920073@hpfelg.HP.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpfcso!hpfelg!korenReferences:
<alfredo.7294@ajahnv.lonestar.org>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpfcso!hpfelg!koren From: koren@hpfelg.HP.COM (Steve Koren) Newsgroups: comp.sys.amiga.tech Subject: Re: grep-ing for "*" with SKsh Message-ID: <13920073@hpfelg.HP.COM> Date: 17 Jul 90 13:21:58 GMT References: <alfredo.7294@ajahnv.lonestar.org> Organization: HP Elec. Design Div. -FtCollins Lines: 31