LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 02-03-2002, 09:35 PM   #1
dj_relentless
Member
 
Registered: Jan 2002
Location: NZ, AKL
Distribution: Redhat 7.1
Posts: 168

Rep: Reputation: 30
grep


anyone know what sort command I'l use to search multiple files (like over 50 or so) for a particular string.
I'm trying to track down where a command is coming from and need to search lots and lots of files cause I've looked in all the ones I thought it'd come from but can't find it.. A boot script to do with setting up the network card it what gives it during the boot process but the script nor the functions file contain it.. its just too weird for me..
 
Old 02-04-2002, 12:32 AM   #2
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
the command that lists files is

ls


to hidden files use

ls -a


to show file sizes and permissions, etc use

ls -l

ls -la /somefolder

to find something


ls /somefolder | grep w*l?ind?his*

willfindthisfile


ls [abc]*[de]

shows all files starting with either a, b, or c and and also ending with either d, or e



Last edited by DavidPhillips; 02-04-2002 at 12:40 AM.
 
Old 02-04-2002, 12:44 AM   #3
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
Nevermind I guess you mean inside the files, sorry



use this


cat filename | grep string



use * or some wildcard form for filenames


some files will freek out the xterm and sound




Last edited by DavidPhillips; 02-04-2002 at 12:49 AM.
 
Old 02-04-2002, 12:48 AM   #4
dj_relentless
Member
 
Registered: Jan 2002
Location: NZ, AKL
Distribution: Redhat 7.1
Posts: 168

Original Poster
Rep: Reputation: 30
ls /somefolder | grep w*l?ind?his*

That wouldn't search within files would it? correct me if I'm wrong but is that listing a dir, sending the output to grep and grep searches the list for the string then displays it on screen? so your displaying file names..

I'm thinking (at work at the mo) of just going
grep -r Intervention *
and I'm hoping that'll search every file on the partition (I'm trying to troubleshoot LFS so its not that big of a partition) to location whats calling this strange word. Does that sound right, I know its a long and painful way to try it but its all I can think of since I have no idea whats trying to call it..or would that not do it? or was I wrong in what your command meant?
 
Old 02-04-2002, 12:50 AM   #5
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
no you should use cat for file contents


ls only outputs filenames
 
Old 02-04-2002, 12:52 AM   #6
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
How can you tell where it came from if you do them all at once?
 
Old 02-04-2002, 12:55 AM   #7
dj_relentless
Member
 
Registered: Jan 2002
Location: NZ, AKL
Distribution: Redhat 7.1
Posts: 168

Original Poster
Rep: Reputation: 30
Because it would tell me which filename the text was contained in.
 
Old 02-04-2002, 12:55 AM   #8
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
I think your right there


grep will list like this


filename: line with string in it



you could do this


grep "string to find" *


Last edited by DavidPhillips; 02-04-2002 at 01:03 AM.
 
Old 02-04-2002, 12:58 AM   #9
dj_relentless
Member
 
Registered: Jan 2002
Location: NZ, AKL
Distribution: Redhat 7.1
Posts: 168

Original Poster
Rep: Reputation: 30
I know it sounds stupid but I can't think of other ways to try it..

Is there a different log file that contains the error output from boot scripts cause I could only fine the log prior to that part of the boot process.
 
Old 02-04-2002, 01:04 AM   #10
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
yep


check dmesg


and also check /var/log/messages




What is the error?

Last edited by DavidPhillips; 02-04-2002 at 01:06 AM.
 
Old 02-04-2002, 01:32 AM   #11
dj_relentless
Member
 
Registered: Jan 2002
Location: NZ, AKL
Distribution: Redhat 7.1
Posts: 168

Original Poster
Rep: Reputation: 30
Found the problem,
I had a space in my hostname in the network file..how silly is that..
 
Old 02-04-2002, 01:43 AM   #12
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
Cool
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
grep ?? can grep us variables? DaFrEQ Linux - Software 4 09-14-2005 12:22 PM
help on grep!!!! sanjith11 Programming 5 01-20-2005 05:43 PM
What does rpm -qa |grep th* (as compared to rpm -qa |grep th) display? davidas Linux - Newbie 2 03-18-2004 01:35 AM
"Undeleting" data using grep, but get "grep: memory exhausted" error SammyK Linux - Software 2 03-13-2004 03:11 PM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:10 PM.

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
Open Source Consulting | Domain Registration