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.
In reply to Re: How to grep some string(IP:port) from text file and print into txt file
by hippo
in thread How to grep some string(IP:port) from text file and print into txt file
by hegaa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |