LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-17-2003, 04:44 PM   #1
Thinking
Member
 
Registered: Oct 2003
Posts: 249

Rep: Reputation: 30
file search


hiho
does anyone know a tool to not only search files, but search some strings IN the files???
thx@ll
 
Old 10-17-2003, 04:57 PM   #2
Kurt M. Weber
Member
 
Registered: Oct 2003
Distribution: Slackware
Posts: 335

Rep: Reputation: 33
man find
man grep
 
Old 10-17-2003, 04:58 PM   #3
Kurt M. Weber
Member
 
Registered: Oct 2003
Distribution: Slackware
Posts: 335

Rep: Reputation: 33
Admittedly, the man pages are rather terse, but at least they'll provide you with some guidance. At the least, they'll give you an idea of what specifically you need to look for with regards to those two commands.
 
Old 10-17-2003, 05:20 PM   #4
Thinking
Member
 
Registered: Oct 2003
Posts: 249

Original Poster
Rep: Reputation: 30
hiho
thx for your reply

and for all of you out there who need a solution for the problem, here is what i found :
for example i want to find the string "hello" in all files in the directory and subdirs of /root
"grep -R hello /root"
 
Old 10-21-2003, 05:47 PM   #5
itsjustme
Senior Member
 
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 45
I had a gripe about grep grating on my grits, but your post has pacifically purged my perplexity.

thanks...
 
Old 10-21-2003, 06:06 PM   #6
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,185

Rep: Reputation: 52
find . -name "*.txt" -print -exec grep hello {} \;

assuming you want to search only specific files.

i thought i should add -print and edited it.

Last edited by whansard; 10-21-2003 at 06:07 PM.
 
Old 10-21-2003, 06:45 PM   #7
itsjustme
Senior Member
 
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 45
Hmmm.. I tried that:
find . -name "*" -print -exec grep 192.168.1.110 {}\;

And got
find: missing argument to '-exec'

Maybe there needs to be a pipe in there. Or maybe grep has to be quoted.
And I don't understand the curly braces in there.

I'm in the / directory and looking, hopefully, on my entire hard drive for the string 192.168.1.110 in any file.

I used Thinking's line and found the string 'nvidia' in the /etc directory as a test. But if I change to the root directory and search for that IP string I get some disk activity for a little bit, but then nothing ever happens. The disk light stops blinking and I don't get back to a prompt until I hit Ctrl-C.

My perplexity is precipitously perpetuating.

I should know grep by now, but I don't.
I should know regular expression by now, but I don't.
I should have another income by now, but I don't.


EDIT: AAACCCKKK!!!! Missed the space after the right curly brace and the \


Last edited by itsjustme; 10-21-2003 at 06:47 PM.
 
Old 10-21-2003, 06:56 PM   #8
itsjustme
Senior Member
 
Registered: Mar 2003
Location: Earth
Distribution: Slackware, Ubuntu, Smoothwall
Posts: 1,571

Rep: Reputation: 45
Man, it's still not doing right.
Doing this:
find . -name "*" -print -exec grep 192.168.1.110 {} \;
started listing every file on the hard drive starting in /boot.

So, can somebody tell me the exact command I need to use to find the string "192.168.1.110" in any file on the hard drive.

Thanks... I think I'm going senile.
 
Old 10-22-2003, 01:04 AM   #9
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,185

Rep: Reputation: 52
find / -type f -exec grep --with-filename 192.168.1.110 {} \;
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
File Search rjohnson244 Linux - Software 4 09-26-2004 02:41 PM
Search for File corley Linux - General 2 08-04-2004 09:40 PM
Find File broken, need search utility, where does WineX install, KDE file roller? Ohmn Mandriva 6 07-05-2004 11:34 PM
How to 'apt-cache search' & 'apt-file search' by distribution? davidas Debian 3 04-19-2004 02:56 PM
How to search for a file montejr Linux - General 5 03-08-2004 02:12 PM


All times are GMT -5. The time now is 04:38 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration