[Chicago-talk] delete the first line in a text file.

Wiggins d'Anconia wiggins at danconia.org
Fri Jul 29 11:45:37 PDT 2005


Jim Thomason wrote:
> Surely we can't let such an obvious challenge go answered by only one
> response! We Perl guys just love to come up with excessive excessively
> short ways to do things.
> 
> 

perl -ni -e 'print unless 1..1' file.txt
perl -ni -e 'print if $.>1' file.txt

A couple characters....

http://danconia.org

> 
> God, I'm so turned on right now.
> 
> -Jim......
> 
> On 7/29/05, Pete Krawczyk <mongers at bsod.net> wrote:
> 
>>Subject: [Chicago-talk] delete the first line in a text file.
>>From: Richard Reina <richard at rushlogistics.com>
>>Date: Fri, 29 Jul 2005 11:08:11 -0700 (PDT)
>>
>>}Anyone know the easiest way remove the 1st line in a
>>}text file.  I was thinking it should be something
>>}like:
>>
>>I personally would use:
>>  # perl -ni.bak -e'print if ++$a > 1;' filename.txt
>>which will create a filename.bak with the original file, and a
>>filename.txt with the first line missing.  (You can shorten to
>>"-ni -e" if you don't need a backup.)
>>
>>-Pete K


More information about the Chicago-talk mailing list