您如何跳过w/awk的最后一行? [英] how do you skip the last line w/ awk?
本文介绍了您如何跳过w/awk的最后一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在用awk处理文件,需要跳过一些行.互联网没有很好的答案.
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
如何跳过最后一行?
推荐答案
使用awk
的一种方法:
awk 'NR > 1 { print prev } { prev = $0 }' file.txt
或者使用sed
更好:
sed '$d' file.txt
这篇关于您如何跳过w/awk的最后一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文