我试图通过不将文件打印到另一个文件来删除文件的前两行。我不是在寻找花哨的东西。这是我对 awk 的(失败的)尝试:
awk '{ (NR > 2) {print} }' myfile
抛出以下错误:
awk: { NR > 2 {print} }
awk: ^ syntax error
例子:
“我的文件”的内容:
blah
blahsdfsj
1
2
3
4
我想要的结果是:
1
2
3
4
最佳答案
使用尾部:
tail -n+3 file
来自手册页:
-n, --lines=K
output the last K lines, instead of the last 10; or use -n +K
to output lines starting with the Kth
关于bash - 使用 BASH 或 awk 或 sed 或其他删除文件的前两行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8857705/