Posted By

noah on 01/28/07


Tagged

file grep find extension multiple


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

basicmagic
Leech
edeustace
smvnet
jeremydouglass


Find/Grep for a string across multiple files with different extensions


 / Published in: Bash
 

Search many files for a string. This example finds the string "thingy." This is useful when I want to find, say, a CSS class name that has changed, and update it in all of my .js, .jsp and .jspf files.

The -niP argument to grep is optional. -n prints line numbers, -i makes search case-insensitive, and -P toggles Perl regular expression syntax. (I'm not sure that -P works under Cygwin.)

  1. find \( -name "*js" -o -name "*jsp" -o -name "*jspf" \) | xargs grep -niP 'thingy'

Report this snippet  

You need to login to post a comment.