?
Solved

Listing files that contain IP addresses

Posted on 2006-11-15
8
Medium Priority
?
265 Views
Last Modified: 2010-08-05
Hi Experts,

how can i list all the files on my system which has IP addresses in them?

Thanks a lot
Vamsi
0
Comment
Question by:vamsi_uk
8 Comments
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 17947056

find / | grep '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'

Note that this will list files with names that appear like IP address.  There's no guarantee that the name is an actual address.



Good Luck,
Kent
0
 
LVL 4

Author Comment

by:vamsi_uk
ID: 17947156
Hi kdo,

I think my question was not clearly written, sorry for that. What i meant is that i want to list the name of the files that contain an IP address inside that file contents (not in the file name)

thanks
0
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 17947248

Use grep to do the same.  Though I suggest that you use it on selected directories and not the entire system.

To search from the current directory (and all subdirectories) try this:

grep -lR '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' .


Kent
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:vamsi_uk
ID: 17947308
Hi kdo,

I have tried the command that you gave me and i got this error message:

root@server1:/data>  grep -lR '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' .

grep: illegal action -- R
Usage: grep -hblcnsviw pattern file . . .

Btw: Im using solaris 7, is that why im getting this problem?
0
 
LVL 46

Expert Comment

by:Kent Olsen
ID: 17947350

Yeah.  The 'R' option means recursively check subdirectories but it isn't a universal option.  I don't know what option you'll need in a Solaris environment.



Kent
0
 
LVL 58

Assisted Solution

by:amit_g
amit_g earned 600 total points
ID: 17948701
Try it this way...

find . | xargs grep -l -e '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'
0
 
LVL 48

Accepted Solution

by:
Tintin earned 600 total points
ID: 17950339
amit_g

close, but no cigar.  Standard Solaris grep doesn't have a -e option, but the POSIX version does, but that doesn't support extended regular expressions.

Change to

find . | xargs egrep -l  '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'
0
 
LVL 4

Author Comment

by:vamsi_uk
ID: 17956353
thanks a lot guys, i've got the expected results with that solution., im increasing the points and sharing between you both.

Cheers!
Vamsi
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question