首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Linux支持"tail +2“吗?

Linux支持"tail +2“吗?
EN

Stack Overflow用户
提问于 2011-05-31 17:26:56
回答 2查看 16.6K关注 0票数 9

我注意到在Solaris ksh中支持tail +2,但是在Red Hat Linux中,会出现一个错误:

代码语言:javascript
复制
c008>> ps -p 4009,6282,31401,31409 | tail +2
tail: cannot open `+2' for reading: No such file or directory

而在Solaris中,

代码语言:javascript
复制
bjbldd>> ps -p 2622,16589,11719,846 |tail +2
16589 ??       0:00 xterm
  846 pts/180  0:00 cscope
11719 pts/180  0:00 cscope
2622 pts/114  0:00 apxcscop

尾部的行用“PID TTY TIME CMD +2”排除。

我知道grep -v PID会起作用的。但我想知道Linux tail是否也有类似的选项?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-05-31 17:31:06

来自tail(1)

代码语言:javascript
复制
   -n, --lines=K
          output the last K lines, instead of the last 10; or
          use -n +K to output lines starting with the Kth

所以试试-n +2--lines=+2

代码语言:javascript
复制
$ ps -p 20085 9530 29993 2069 2012 | tail -n +2
 2012 ?        Sl     0:00 /usr/bin/gnome-keyring-daemon --daemonize --login
 2069 ?        S      0:00 /usr/bin/dbus-launch --exit-with-session i3
 9530 ?        Sl     0:01 /usr/lib/udisks/udisks-daemon
20085 ?        S      0:00 /usr/sbin/apache2 -k start
29993 ?        S      0:00 [kworker/1:0]
$ 
票数 20
EN

Stack Overflow用户

发布于 2014-02-27 04:25:24

我熟悉Solaris上的tail +2语法,但它似乎不能在Ubuntu上工作。

来自超级用户的这个答案似乎是有效的:

代码语言:javascript
复制
tail --lines=+100 <file> 

来源:https://superuser.com/questions/62970/unix-cat-starting-from-line

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6185543

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档