本文介绍了我们如何在UNIX中删除文件的最后7行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用unix命令从csv文件中删除最后7行.
How to remove last 7 lines from the csv file using unix commands.
例如-
abc
bffkms
slds
行开始1
行开始2
行开始3
行开始4
行开始5
行开始6
行从7开始
abc
bffkms
slds
Row started 1
Row started 2
Row started 3
Row started 4
Row started 5
Row started 6
Row started 7
我想从上述文件中删除最后7行.请提出建议.
I want to delete the last 7 lines from above file. Please suggest.
推荐答案
您可以使用head
head -n-7 file
从手册页:
-n, --lines=[-]K
print the first K lines instead of the first 10;
with the leading '-', print all but the last K lines of each file
喜欢:
kent$ seq 10|head -n-7
1
2
3
这篇关于我们如何在UNIX中删除文件的最后7行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!