jadelennox: Demonic Tutor, Jadelennox: my Magic card (demonic tutor)
[personal profile] jadelennox posting in [community profile] command_liners
Little trick I do all the time when I'm looking for a string in a source tree:

find . -type f -exec egrep -H "string I'm seeking" {} \;

The things that vary:

find 
     base command, doesn't change
. 
     the top directory you're seeking in.  Could put a relative or absolute path here.
-type f 
     Narrowing down the kind of files you're seeking, in this case to regular files. 
     You could narrow it down in other ways, e.g. -name "*.c"
-exec egrep -H "string I'm seeking" {} \;
     the grep command in question. 
     The only thing I have a very here is the egrep switch (and the string).
     -H lists filename and the match
     -l just lists the filename; less informative but cleaner.
     {} \; is necessary syntax for the exec argument to find.

Date: 2013-06-07 09:28 pm (UTC)
doldonius: (Default)
From: [personal profile] doldonius
Wouldn't egrep -r "target string" * do the same thing?

Date: 2013-06-11 09:15 am (UTC)
pauamma: Cartooney crab holding drink (Default)
From: [personal profile] pauamma
Other commands you may want to look at: hg grep (or git grep) and my favorite: less `grep -rl string dir` (to display all files that contain string, using less)

Profile

command_liners: A command line prompt with a blinking cursor after it, green against black. (Default)
Command Liners

September 2014

S M T W T F S
 123456
78910111213
1415 1617181920
21222324252627
282930    

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 20th, 2017 10:05 pm
Powered by Dreamwidth Studios