[ale] using find
Danny Cox
danny at compgen.com
Mon Aug 21 12:47:56 EDT 2000
Ken,
On Mon, 21 Aug 2000, Mike Kachline wrote:
> On Mon, 21 Aug 2000, Ken Nagorski wrote:
>
> > Hi,
> >
> > I want to search an entire file system and pipe the output to a
> > file. This is waht I tried, doesn't redirect? anyone know why? Or have a
> > better way to find a string. If you are wondering what this is I am trying
> > to find out where the new Debian dist "potato" stores the IP address's for
> > when it boots and sets up networking.
> >
> > find / -exec grep 216.151.155.78 {} \; >IPADDRESS
> <snip>
>
> My hunch is that you need to escape out the "." for grep...
>
> find / -exec grep 216\.151\.155\.78 {} \; > IPADDRESS
> <snip>
I agree with Mike, but will add another snippet for better
efficiency:
find / -print | xargs grep '216\.151\.155\.78' >IPADDRESS
xargs will read stdin and build a command line until it becomes a
certain size, execute it, and start again. This is much more efficient
'cause grep is only run for every N files, rather than for each file
(fork is efficient, but not THAT efficient).
Another thought is to search only text files. It's a bit more
complex:
find / -type f -print | xargs file | grep text | sed 's/:.*//' \
>/tmp/textfiles
xargs grep '216\.151\.155\.78' </tmp/textfiles >IPADDRESSES
of course, you could do this all in one swell foop, but keeping a list
of text files around is oftentimes handy.
Danny
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.
More information about the Ale
mailing list