in reply to Removing the First Line

With quoting adapted for Windows, the following does the magic using a scalar context range operator:

perl -ne "@A=split /,/; print join(q(,), @A[0 .. 3]),qq(\n) if 2 .. -1 +;" temp.txt

Note that a file line number match is implied by the scalar context range operator when numeric constants are used.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Removing the First Line
by jwkrahn (Abbot) on Jan 30, 2007 at 02:48 UTC
    I don't think that -1 will work with $., better to use eof.
    perl -lne"@A=split /,/; print join(q(,), @A[0 .. 3]) if 2 .. eof" temp +.txt