Solved

Listing files that contain IP addresses

Posted on 2006-11-15
8
211 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 45

Expert Comment

by:Kdo
Comment Utility

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
Comment Utility
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 45

Expert Comment

by:Kdo
Comment Utility

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
 
LVL 4

Author Comment

by:vamsi_uk
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 45

Expert Comment

by:Kdo
Comment Utility

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 150 total points
Comment Utility
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 150 total points
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now