Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keyword searching a C++ program on Linux 1

Status
Not open for further replies.

cesfe

Technical User
Aug 13, 2003
6
0
0
US
need to find where in the program a particular variable is defined or used. The program is in C++ resident on a Linux system.
 
But the source code is spread over several directories and .cpp's and .h's. It would be hard to all of them to one file and then search through it. There is got to be a better way. Thanks for taking time.
 
[tt]grep -Hr 'string' /path/to/source/code[/tt]
should print out the filename followed by the line [tt]string[/tt] appeared on.

//Daniel
 

Check the system, if you have access to the development tool cscope, it is quite powerful and useful.

You can use it to search an entire project's list of source files for any variable you want.

Cheers!

 
The grep command worked beautifully. Thank you Dan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top