How to delete everything in a file after 5th line using awk?
I can do it by sed, but these days I am moving from sed to awk.
How to delete everything in a file after 5th line using awk?
I can do it by sed, but these days I am moving from sed to awk.
awk 'NR <= 5' inputfile would do it (it prints whenever NR, the record number, is less than or equal to five.
awk 'NR > 5{exit}1' yourfile
would quit "awk" as soon as the 6th line is reached. But prior to that, the default action would apply, thereby printing lines 1..5.