How can I read lines from the end of file in Perl?

后端 未结 11 1938
夕颜
夕颜 2020-12-06 02:41

I am working on a Perl script to read CSV file and do some calculations. CSV file has only two columns, something like below.

One Two
1.00 44.000
3.00 55.000         


        
11条回答
  •  旧巷少年郎
    2020-12-06 03:09

    If you know the number of lines in the file, you can do

    perl -ne "print if ($. > N);" filename.csv
    

    where N is $num_lines_in_file - $num_lines_to_print. You can count the lines with

    perl -e "while (<>) {} print $.;" filename.csv
    

提交回复
热议问题