Perl: How do I remove the first line of a file without reading and copying whole file

前端 未结 6 1254
刺人心
刺人心 2021-01-01 19:06

I do have a whole bunch of files in a directory and from every file I want to remove the first line (including carriage return). I can read the whole file into an array of s

6条回答
  •  Happy的楠姐
    2021-01-01 19:39

    perl -n -i -e 'print unless $. == 1' myfile
    

    This is similar to stocherilac's answer.

    But, in any case (and in all the others answer given!) you are always reading the full file. No way of avoiding that, AFAIK.

提交回复
热议问题