头上有什么相反的?(What's the opposite of head? I want all but the first N lines of a file)

编程入门 行业动态 更新时间:2024-10-27 00:30:03
头上有什么相反的?(What's the opposite of head? I want all but the first N lines of a file)

给定一个长度不明的文本文件,我如何读取,例如文件的前2行呢? 我知道tail会给我最后的N行,但我不知道N是提前的。

所以对于一个文件

AAAA BBBB CCCC DDDD EEEE

我想要

CCCC DDDD EEEE

和一个文件

AAAA BBBB CCCC

我会得到的

CCCC

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.

So for a file

AAAA BBBB CCCC DDDD EEEE

I want

CCCC DDDD EEEE

And for a file

AAAA BBBB CCCC

I'd get just

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应该给你你要查找的输出(从3开始)。

tail --help gives the following:

-n, --lines=K output the last K lines, instead of the last 10; or use -n +K to output lines starting with the Kth

So to filter out the first 2 lines, -n +3 should give you the output you are looking for (start from 3rd).

更多推荐

本文发布于:2023-07-19 20:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1186769.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么   头上   head   lines   file

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!