Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to list all of the files that include a function, e.g., matrixCal.

How can I to do this in linux?

share|improve this question
1  
what programming language? –  maxschlepzig Jun 16 '11 at 18:43
    
Linux environment. –  UltraCommit Jun 17 '11 at 7:56
    
@UltraCommit - ? –  maxschlepzig Jun 17 '11 at 8:27
add comment

3 Answers

up vote 5 down vote accepted

Would grep be ok?

grep -R matrixCal /location/of/your/code
share|improve this answer
1  
It works, thanks. –  bit-question Jun 16 '11 at 19:53
add comment

You might be interested in the program ack. It's specifically designed for searching through source code directories and returning useful things in an easy to read format. Basically it does the same thing as grep but in a much more friendly format.

share|improve this answer
add comment

The traditional approach is to create an index of function and variable definitions for your source code, and use your editor to search this index. The traditional indexing command is called ctags and creates a file called tags that can be used in vi. Emacs comes with a similar etags command (the file is called TAGS).

For example, for a C source tree, here is how you might generate the TAGS file for Emacs:

find -type f -name '*.[hc]' -exec etags {} +

For a large source tree checked out under Subversion, here are two refinements: ignore .svn directories, and cope with file hierarchies that are so long that the command line length limit would be exceeded (resulting in a truncated file because each successive invocation of etags would rewrite the file from scratch).

: >TAGS
find -type d -name .svn -prune -o \
     -type f -name '*.[hc]' -exec etags -a {} +

Then, in Emacs, run M-x visit-tags-table once and select the TAGS file. Put your cursor over the word matrixCal, and press M-. (find-tag) to jump to the definition (opening the file containing the definition if necessary). To iterate between occurrences, run M-x tags-search, enter ^matrixCal$ to go to one occurrence, and use M-, (tags-loop-continue) to jump to the next occurrence. In the TAGS buffer, M-x occur RET matrixCal RET will give you an overview of where the symbol is used.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.