[plug] grep command
Russell Steicke
russells at plug.linux.org.au
Mon Sep 9 18:04:28 WST 2002
On Mon, Sep 09, 2002 at 05:23:51PM +0800, Jon Miller wrote:
> Need a command to search through a series of directories and files
> for a line.
>
> I issued the command grep -ri imap_open *.php3
>
> Is this correct if looking for the string imap_open (not sure of the
> casing hence the -i), but I need it to search through all php3
> files.
The shell here will expand *.php3 before grep ever sees it, so that
won't work. Try this:
find . -type f -name \*.php3 -print0 | xargs -0 grep -i imap_open
It's worth working out how to use find and xargs, they're very good
for tasks like this. In particular, the -print0 and -0 arguments work
together to handle filenames with any strange characters in them.
More information about the plug
mailing list