Tuesday, 29 July 2008

Handy foreach + grep

Today I wanted to list a bunch of python files that used a setValue command.

To get some colour in the output

--colour=always

Ignore case

-i

Show line number

-n

Put it all together

grep --colour=always -i -n setValue

And combine with the foreach.

foreach j (*)
foreach? echo $j
foreach? cat $j |grep --colour=always -i -n setValue
foreach? end

Lovely.

No comments: