Reputation: 8606
I am processing a file with awk and need to skip some lines. The internet dosen't have a good answer.
So far the only info I have is that you can skip a range by doing:
awk 'NR==6,NR==13 {print}' input.file
OR
awk 'NR <= 5 { next } NR > 13 {exit} { print}' input.file
You can skip the first line by inputting:
awk 'NR < 1 { exit } { print}' db_berths.txt
How do you skip the last line?
Upvotes: 18
Views: 18748
Reputation: 54502
One way using awk
:
awk 'NR > 1 { print prev } { prev = $0 }' file.txt
Or better with sed
:
sed '$d' file.txt
Upvotes: 20