[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding file with specific Text string



On Fri, 2003-04-04 at 17:00, mike808@users.sourceforge.net wrote:
> Jeff Licquia <jeff@licquia.org> replied:
> > find <dir> -type f -print | xargs fgrep -l 'LSTMIS1'
> 
> Since Word files tend to have names that have spaces in them,
> this will likely "blowed up real good".

Hmm.  Good point.

> Try this instead:
>   find <dir> -type f -print0 | xargs -0 fgrep -l 'LSTMIS1'
> 
> Note, the -print0 (dash-print-zero) and xargs -0 (dash-zero) arguments
> are specific to GNU implementations. YMMV.

On Linux, the above is probably best.  For a more portable solution, do
this:

find <dir> -type f -print | sed 's/^/"/' | sed 's/$/"/' | xargs fgrep -l 'stuff'

That will wrap each filename in quotes.
-- 
Jeff Licquia <jeff@licquia.org>

-
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.