>type !.txt a b c d e f g h pattern j k l pattern 1 2 3 4 5 6 7 8 9 10 A >perl -ne "next unless /pattern/;print scalar <> for 1..10;last" !.txt j k l pattern 1 2 3 4 5 6