perl -lne "print qq($.)" two_lines.log 13_lines.log 1 2 3 #<--here starts second file 4 5 6 7 8 9 10 11 12 13 14 15 perl -lne "print qq($.); close ARGV if eof" two_lines.log 13_lines.log 1 2 1 #<--here starts second file 2 3 4 5 6 7 8 9 10 11 12 13