in reply to How to grep some string(IP:port) from text file and print into txt file

I was going to suggest that this

perl -lane 'print $F[1] if $. < 5;' test.txt

will perform to the spec. However I then noticed that for some reason you didn't want the 4th line of input to match and I cannot spot why that would be the case. Perhaps there is an error in your spec? Consider How to ask better questions using Test::More and sample data.

  • Comment on Re: How to grep some string(IP:port) from text file and print into txt file
  • Download Code