头的相反是什么?我想要除文件的前N行之外的所有 [英] What's the opposite of head? I want all but the first N lines of a file
本文介绍了头的相反是什么?我想要除文件的前N行之外的所有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定一个未知长度的文本文件,如何读取文件的前两行,例如所有但?我知道 tail
会给我最后N行,但我不知道N是提前的。
Given a text file of unknown length, how can I read, for example all but the first 2 lines of the file? I know tail
will give me the last N lines, but I don't know what N is ahead of time.
对于文件
AAAA
BBBB
CCCC
DDDD
EEEE
我想要
CCCC
DDDD
EEEE
AAAA
BBBB
CCCC
我会得到
CCCC
推荐答案
tail --help
给出以下:
-n, --lines=K output the last K lines, instead of the last 10;
or use -n +K to output lines starting with the Kth
第一个 2
行, -n +3
应该提供您正在寻找的输出(从第三个开始)。
So to filter out the first 2
lines, -n +3
should give you the output you are looking for (start from 3rd).
这篇关于头的相反是什么?我想要除文件的前N行之外的所有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文