Archive

Posts Tagged ‘grep’

Find words in files in linux

March 7th, 2011 No comments

After wanting to find text inside of files in Ubuntu I ran across a nice little post. They way it was described to do it works great.  It uses the grep command.

Say you want to find some text called “my_function” in your scripts folder located at the /home/michael/scripts/ directory. Simply run the following command:

grep -i -n -r 'my_function' /home/michael/scripts/

Here is what is happening:
grep is function name to search a pattern in files
-i means ignore case
-n means output line number
-r search recursively

This makes it easy to edit the files with vim, and then jump straight to the line that you needed to edit.

Categories: Scripts Tags: , , ,