LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 03-22-2003, 07:30 PM   #1
duhduhdude
LQ Newbie
 
Registered: Mar 2003
Posts: 5

Rep: Reputation: 0
trying to use find and grep, but don't know well enough.


hi

i am trying to use find and grep to find out all occurrences of a particular ip address in any of my files.

i am using find * /| grep xx.xxx.xx.xx

and i cannot get any files. can somebody ehlp me with the right syntax ?
 
Old 03-22-2003, 07:44 PM   #2
Palin
Member
 
Registered: Feb 2003
Location: A Meatlocker, well feels like one
Distribution: Gentoo
Posts: 292

Rep: Reputation: 30
well the usage for grep is

grep <switches> <pattern> <file list>

to find a string in a set of files I use
grep -H <pattern> <file list>

I think you use find where <file list> is not really sure though
you should check the man page for the rest of the switches for grep.
 
Old 03-22-2003, 08:21 PM   #3
cuckoopint
Member
 
Registered: Feb 2003
Distribution: Debian
Posts: 797

Rep: Reputation: 30
Quote:
I think you use find where <file list> is not really sure though
do you mean grep's -r (recursive) option?
 
Old 03-22-2003, 08:48 PM   #4
duhduhdude
LQ Newbie
 
Registered: Mar 2003
Posts: 5

Original Poster
Rep: Reputation: 0
this one doesn't seem to work

i tried using grep with -H as well as -r option. doesn't seem to work.
 
Old 03-22-2003, 09:03 PM   #5
cuckoopint
Member
 
Registered: Feb 2003
Distribution: Debian
Posts: 797

Rep: Reputation: 30
well, what do you get, vs. what do you want to get?

Code:
grep -r xx.xxx.xx.xx /
 
Old 03-22-2003, 09:15 PM   #6
duhduhdude
LQ Newbie
 
Registered: Mar 2003
Posts: 5

Original Poster
Rep: Reputation: 0
i am not getting nothing. basically i just want to find all files that contain an occurrence of a particular ip address.

just as in windows, as we search all files and folder, including system and hidden, for text containing duhduhdude, we may get for example file idiots.txt which contains a text saying "the first idiot is duhduhdude, we are yet to find more"

so that i can go to idiots.txt and edit it.
 
Old 03-22-2003, 09:21 PM   #7
cuckoopint
Member
 
Registered: Feb 2003
Distribution: Debian
Posts: 797

Rep: Reputation: 30
Quote:
i am not getting nothing.
Either:
1. you're syntax is wrong. double check your syntax
2. you don't have permissions for the files
3. no file exists with the ips.

One way to check this would be to search for something obvious, like:
grep -r a /

which would search for 'a' in all files. after you get some results to show the command actually works, press ctrl-c to stop it.

If this worked, but the previous did not, no files exist with your ip. maybe create a temp file with the ip, and search again. This time, you should atleast get this one result.
 
Old 03-22-2003, 09:28 PM   #8
duhduhdude
LQ Newbie
 
Registered: Mar 2003
Posts: 5

Original Poster
Rep: Reputation: 0
i created a file duh.txt on the root folder with that particular ip "xxx.xx.xx.xx"

grep -r xxx.xx.xx.xx / did not yield me any result did not even show me that file.
 
Old 03-22-2003, 09:39 PM   #9
cuckoopint
Member
 
Registered: Feb 2003
Distribution: Debian
Posts: 797

Rep: Reputation: 30
ok, let's try one last thing.
create a file with the ip address in your home dir.
then, do:
grep -r "xxx.xx.xx.xx" ~/*

if this works, it may be that it was b/c of permission problems or the use of quotes in the expression.

if not, maybe you're grep is messed up.
 
Old 03-22-2003, 09:44 PM   #10
duhduhdude
LQ Newbie
 
Registered: Mar 2003
Posts: 5

Original Poster
Rep: Reputation: 0
thanks so much, that worked.
 
  


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
Using find and grep - how to exclude a result ? graziano1968 Linux - General 13 12-04-2010 11:02 PM
using find /grep gamor Linux - Newbie 14 04-13-2005 03:36 PM
find with grep and replace it dominant Linux - Newbie 4 03-03-2004 02:11 PM
Using grep to find only first instance roballen Linux - General 2 01-29-2004 04:21 AM
help me find grep-2.5.1 shanenin Linux - Software 1 01-23-2004 10:01 PM


All times are GMT -5. The time now is 12:31 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration