linux + match only VALID IP from text file into other file

Posted by yael on Server Fault See other posts from Server Fault or by yael
Published on 2012-11-15T08:27:22Z Indexed on 2012/11/15 11:07 UTC
Read the original article Hit count: 197

Filed under:
|
|
|
|

please advice how to match only the valid IPs ( 255.255.255.255 ) from the file.txt and insert only the valid IP into VALID_IP.txt file

  • ( see VALID_IP.txt for example )

the solution should be implemented in my ksh script ( so perl or sed or awk is fine also )

more file.txt

     e32)5.500.5.5*kjcdr
     ##@$1.1.1.1+++jmjh
     1.1.1.1333
     33331.1.1.1
     @5.5.5.??????
     ~3de.ede5.5.5.5
     1.1.1.13444r54
     192.9.30.174
     &&^#%5.5.5.5
     :5.5.5.5@%%^^&*
     :5.5.5.5:
     **22.22.22.22
     172.78.0.1()*5.4.3.277

example of VALID_IP.txt file

     1.1.1.1
     192.9.30.174
     5.5.5.5
     5.5.5.5
     5.5.5.5
     22.22.22.22
     172.78.0.1

© Server Fault or respective owner

Related posts about linux

Related posts about perl