Korn and searching
Jason Parker-Burlingham
jasonp at uq.net.au
Wed Nov 13 22:57:58 EST 2002
JJ Neff <jjneff at yahoo.com> writes:
> Can someone indicate the syntax for searching for a keyword in any file on
> aUnix box that uses Korn shell?
>
> Im assuming it's some kind of
> find / -name * > xargs less > grep Keyword
Good lord no. I can't even begin to point out what's wrong with
that[1].
If you're using GNU grep, and maybe other variants you can just use:
$ grep -rF keyword .
That greps, (r)ecursively, for any mention of the literal string
(that's what -F does) "keyword" in any file from the named directory
(in this case the current directory) down.
Other useful variants include:
$ grep -rilw regexp . # print filenames of recursively matched
# files.
$ less $(grep -rFl string .) # open matching files in less(1)
To do it the way you wanted to, the correct syntax would be:
$ find / -type f | xargs grep Keyword
as suggested just now by Mark Musone.
jason
[1] : Okay, for a start you are trying to use output redirection
operators to create pipes between processes; all that that
command line will do is make a file in the current directory
called "xargs", and maybe one called "grep".
--
||----|---|------------|--|-------|------|-----------|-#---|-|--|------||
| ``It's just a big electric typewriter.'' |
| |
||--|--------|--------------|----|-------------|------|---------|-----|-|
More information about the nflug
mailing list