in reply to perl one liner to print a line

perl -ne'print if $. == 4' file.txt

Replies are listed 'Best First'.
Re^2: perl one liner to print a line
by ikegami (Patriarch) on Dec 12, 2008 at 02:00 UTC
    You can exit sooner with
    perl -ne'print, last if $. == 4'

      I prefer:

      perl -ne'print and close ARGV if $. == 4' file.txt

      It works better with multiple files on the command line.      ;-)