[Cialug] Find Files with String

Paul Gray gray at cs.uni.edu
Fri Dec 11 10:49:20 CST 2009


Todd Walton wrote:
> Can anyone suggest a bash one liner to find all text files that have a
> certain string in them and print the names?
> 
> I've been playing around with 'for-do-done', but I'm wondering now if
> maybe 'find' might be better.

grep --exclude-dir=/proc --exclude-dir=/sys --exclude-dir=/dev -D skip -d 
recurse 'text-in-file' /

More robust examples (with find and/or xargs) are bound to follow.  But do you 
want robustness, or a one-liner?
-- 
Paul Gray                                         -o)
314 East Gym, Dept. of Computer Science           /\\
University of Northern Iowa                      _\_V
  Message void if penguin violated ...  Don't mess with the penguin
  No one says, "Hey, I can't read that ASCII attachment ya sent me."


More information about the Cialug mailing list