Maybe OT - Grepping the locate command
Martin Pitt
martin.pitt at ubuntu.com
Wed Mar 3 10:46:29 GMT 2010
donn [2010-03-03 12:39 +0200]:
> I would like to search through the *contents* of the files returned by
> locate. So far I have not had much luck.
>
> locate *.ods | grep blah
> (No good because it greps the filenames, not their contents)
> [...]
> ls | cat
> (I expected a long cat of all the files listed. I got the same as ls on
> its own. I am sure I am missing something basic here.)
What you are looking for is "xargs". This calls a command on all files
whose paths are provided on stdin.
locate *.ods | xargs grep blah
ls | xargs cat
will do what you want.
Martin
--
Martin Pitt | http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
More information about the sounder
mailing list