perl -pe 'close ARGV if $. == 5' file1 file2 ...
Update: The code above fails if one if the files is less than 5 lines long! This works better:
perl -pe 'close ARGV if $. == 5 or eof' file1 file2 ...
buckaduck
In reply to Re: how to print first 5 lines of a file
by buckaduck
in thread how to print first 5 lines of a file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |