?
Solved

Listing files that contain IP addresses

Posted on 2006-11-15
8
Medium Priority
?
260 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
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 several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:
Suggested Courses
Course of the Month12 days, 17 hours left to enroll

777 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