finding words in files.
Hello,
I am looking for this `struct messages_sdd_t` and I need to search through a lot of *.c files to find it. However, I can't seen to find a match as I want to exclude all the words 'struct' and 'messages_sdd_t'. As I want to search on this only 'struct messages_sdd_t' The reason for this is, as struct is used many times and I keep getting pages or search results. The directory I am searching in, has another directories so it will have to search recursively. I have been doing this without success: Code:
find . -type f -name '*.c' | xargs grep 'struct messages_sdd_t' Code:
find . -type f -name '*.c' | xargs egrep -w 'struct|messages_sdd_t' |
My first thought was to give you the "find .. -exec {} \;" syntax.
That would work ... but a better idea might be to acquaint you with "gid" ("id-utils"). Please do this: 1. See if you can find "id-utils" in your package manager. Install it. Otherwise, you can download and build the tarball from here. 2. "cd" to the top-level of your project, and type "mkid" <= this creates an id-utils index of your entire source tree. it just takes a few moments - even for a large project 3. Type "gid messages_sdd_t" You should see all instances of "messages_sdd_t", including the definition. 4. You can combine "gid XYZ" with "less", "grep" and other tools easily to filter your search. You can use id-utils with "vi" or "emacs" to lookup code directly in your text editor. 'Hope that helps .. PSM PS: find . -name "*.c" -exec {} grep messages_sdd_t \; |
When I try your first example, I get the expected results, so I'm not sure what is not working. You may want to try using a regular expression for more control like this:
Code:
find . -type f -name '*.c' | xargs grep -e "struct.*messages_sdd_t' |
Try id-utils. Satisfaction guaranteed :)
|
All times are GMT -5. The time now is 08:28 PM. |