Skip to main content

Find Command that returns line number of the string

I have a bunch of files organized into directories..All these are text files (c/c++). I am trying to understand this code and i need to look at the declarations of many variables..How can i use find command to get the exact location( File Name with line number(s) ) using Find command in ubuntu linux?? Or is there any graphical tool for doing the same?

Answer:
You can do this with grep. grep -n 'search-term' *.c will give you the filename and line number where the term appears.

This will fail if there are sub directories 

 You can use grep -nr 'search-term' *.c

-H, --with-filename  
 

Comments