Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

hi dear friends and good morning

The following question may be complicated and critical for my systems

I have 4 Linux machines with cluster

My target is to find all kind of IP address ( in every file in the linux system

remark: need to scan each file in the linux system and verify if the file include IP address if yes need to print the IP

as the following

more /etc/inet/file.example1

more /etc/dir/file1.example2 TCP


Can I get some creative suggestion that search all IP address and print them


share|improve this question
up vote 1 down vote accepted

This will print the full line that contains something that resembles an IP address. It doesn't check to see if its octets are in the range 0-255.

grep -Er '\<([0-9]{1,3}\.){3}[0-9]{1,3}\>' /*

to only print the address without the rest of the line add the -o option. To disable printing the filename add the -h option.

You could replace the \< and \> delimiters with [[:space:]].


Here's one that may be suitable for cases that include asterisks:

grep -Er '[[:space:]]((\*|[0-9]{1,3})\.){3}(\*|[0-9]{1,3})[[:space:]]' /*
share|improve this answer
little problem if the IP is for example 3.3.*.* can your syntax support this? – lidia Sep 7 '10 at 8:29
@lidia: see my edit – Dennis Williamson Sep 7 '10 at 9:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.