Thursday 15 May 2014

regex - replace lines from file that match patterns in another file -


I am writing a script, but at this time, I am drawing blank in my head.

So basically, I have 1.txt , which has a bunch of IPs:

  1.1.1.1 2.2.2.2 3.3 .3.3   

And I have another file 2.txt , which is something like this:

  1.1. 1.1 2.2.2.2 3.3.3.3 Bad IP 4.4.4.4 5.5. Anything in 5.5   

should end in 2.txt , so after processing, 2.

  4.4.4.4 5.5.5.5   

Try to use the script to attract the blank

  While ` Cat in line 2.txt` IS '/' $ line '// g' 2.txt   

Can someone give me some hints?

GNU

  sed -r's # (. *) # / \ 1 / d # 'file1 | Sed -f-file2    

No comments:

Post a Comment