Link to home
Start Free TrialLog in
Avatar of vamsi_uk
vamsi_uk

asked on

Listing files that contain IP addresses

Hi Experts,

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

Thanks a lot
Vamsi
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image


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
Avatar of vamsi_uk
vamsi_uk

ASKER

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

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
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?

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
SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks a lot guys, i've got the expected results with that solution., im increasing the points and sharing between you both.

Cheers!
Vamsi