Linux Geek‎ > ‎

Search in Files from Command Line

posted Oct 15, 2009 12:28 AM by Bruno Braga   [ updated Oct 15, 2009 1:29 AM ]

This becomes handy once in a while, if you are connecting to some server via SSH, or simply don't want to open a GUI text editor for a simple search.

for f in `find ./ -name '*' 2>/dev/null`; do grep -nsiHI keyword $f; done

This would search recursively from the current directory. If you do not wish that, just use a simpler "for f in *", it should do the trick. The arguments from grep are also pretty cool, and it is worth to take a look if you have time.

 BRAGA, Bruno

 



Brazilian currently based in Japan, working on Information Technology.