LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-08-2004, 07:59 AM   #1
juliettree
LQ Newbie
 
Registered: Apr 2004
Location: Kent, UK
Posts: 12

Rep: Reputation: 0
Help With GREP Command


Hi

I'm just getting to grips with all the Linux lingo but need some help on using the GREP command

I believe this can be used to find strings of data within files but not sure of the syntax. And can you use it to search more than just the current directory you are in?

Eg. I need to find the file that has our SMTP Server IP address in. I have the IP address but a little unsure of where to start looking. All the files I thought it may be in it isn't!

Thanks
 
Old 04-08-2004, 09:00 AM   #2
juliettree
LQ Newbie
 
Registered: Apr 2004
Location: Kent, UK
Posts: 12

Original Poster
Rep: Reputation: 0
I've cracked it!

Using grep -l 'ipaddress' *

Had to go through the various directories hanging directly off / but got there in the end.

Was long winded though so if anyone knows how to search through all the directories in one try or just has a better way then please let me know for future reference!

Thanks
 
Old 04-08-2004, 09:15 AM   #3
kvedaa
Member
 
Registered: Mar 2004
Location: Virginia
Distribution: PacketProtector
Posts: 331

Rep: Reputation: 30
One method of performing a recursive grep is:

find . –type f –print | xargs grep “Item to search for here”

On the boxes that I admin I put this into a little shell script that I call rgrep, so that I can feed my search value in without needed to retype this line everytime I want to perform a recursive grep.
 
Old 04-08-2004, 09:44 AM   #4
juliettree
LQ Newbie
 
Registered: Apr 2004
Location: Kent, UK
Posts: 12

Original Poster
Rep: Reputation: 0
Hi

Thanks.

Gave it a go and was definitely a lot quicker!

Maybe this linux stuff is starting to fall into place at last!
 
  


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
how to use grep command sharonyiisl Linux - Newbie 7 05-28-2006 04:46 PM
grep command itz2000 Linux - Newbie 2 09-21-2005 08:06 PM
grep command in c????? alnreddy Linux - Software 1 12-30-2004 02:01 AM
Develop grep command pengui Programming 1 10-16-2004 02:48 AM
grep command cuss Linux - General 7 02-14-2003 10:23 AM


All times are GMT -5. The time now is 06:22 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