gpt4 book ai didi

bash - 使用 BASH 或 awk 或 sed 或其他删除文件的前两行

转载 作者:行者123 更新时间:2023-11-29 08:42:07 24 4
gpt4 key购买 nike

我试图通过不将文件打印到另一个文件来删除文件的前两行。我不是在寻找花哨的东西。这是我对 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com