LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 01-30-2007, 07:31 AM   #1
Sapper1729
LQ Newbie
 
Registered: Aug 2006
Posts: 7

Rep: Reputation: 0
Smile Help please with searching files


Hi, I am looking for a bit of help, I would like to perform a search of all the files in all the directories in the Linux file system looking for a certain word, this word is tests, the thing is I need this to look into Bin files so I was thinking of trying with the nm command and using this with grep, I can't seem to get this to work, is there anyone who can help me. Maybe I could use cat to look into the binary files through the entire directory structure looking as all files that have the specified word and output the results to a file, maybe something like:

cat * | grep -r "tests" > /logfile.log

Thanks in advance

 
Old 01-30-2007, 07:38 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: OpenSUSE 12.1 CentOS 6.2
Posts: 8,998

Rep: Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349Reputation: 1349
Code:
find . -exec grep -H pippo {} \;
but sincerely I don't know exactly what is the behaviour of grep with binary files. Sometimes I see something like "Binary file ./a.out matches", as result.
 
Old 01-30-2007, 07:41 AM   #3
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
It might prove difficult with binaries, since the text strings inside might not be "written" exactly as in regular text files. Hexdump shows, for example, some strings too but sure takes come time anyway, going trough all the files on your system is pretty big a process, at least if you read everything trough for a keyword. It is possible but takes time, so your task has to be important. I wouldn't rely on grep's actions on binary files, though.
 
Old 01-30-2007, 08:09 AM   #4
Sapper1729
LQ Newbie
 
Registered: Aug 2006
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks to both of you for such a speedy response, I can now narrow this down to a particular dir /lib so that is the only dir that has the .so binary files that I need to search for the word tests, what would you suggest I use as you guys seem to be the experts and I have little knowledge, but B0uncer you did help me before with the LDAP queries which really worked well, top man.....
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching For Files carlosinfl Linux - General 4 01-06-2007 10:01 PM
searching for files deept Programming 1 08-15-2005 11:54 AM
help searching files jorasmi Slackware 3 02-02-2005 04:06 AM
Searching files on Linux dasoslukos Linux - Software 2 10-24-2004 11:12 PM
Searching files for strings tmoorman Linux - Software 4 01-08-2004 01:46 PM


All times are GMT -5. The time now is 04:14 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration