What's the opposite of head? I want all but th

2019-01-16 10:52发布

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

8条回答
我想做一个坏孩纸
2楼-- · 2019-01-16 11:24

Try sed 1,2d. Replace 2 as needed.

查看更多
别忘想泡老子
3楼-- · 2019-01-16 11:26

Assuming your version of tail supports it, you can specify starting the tail after X lines. In your case, you'd do 2+1.

tail -n +3

[mdemaria@oblivion ~]$ tail -n +3 stack_overflow.txt
CCCC
DDDD
EEEE
查看更多
登录 后发表回答