Possible Duplicate:
Search for a text pattern in linux
In bash, I was wondering if there were any commands that would let you know if a particular string you are looking for exists within the files located in the current directory you are in.
Say you are looking for the function 'toUpperCase()' within a set of C files in your current directory. There are a lot of files, so you wouldn't want to manually open each one up using vim and check for the string 'toUpperCase' because that would take a lot of time. If not a bash command line, is there another method to do this efficiently?
Answer
With grep
:
grep -R "toUppercase()" *
Or, if you have ack-grep installed, simply:
ack-grep "toUppercase"
If you want to limit the search in C files, with ack-grep
:
ack-grep -cc "toUppercase()"
ack-grep
can also be installed on OSX but the executable is called just ack
.
No comments:
Post a Comment