加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

如何超时Bash命令并计算发送到stdout的行数?

发布时间:2020-12-15 21:39:25 所属栏目:安全 来源:网络整理
导读:我想做一些像超时12s tail -f access.log | wc -l但是我没有看到wc的输出.能做到这一点需要做些什么? 解决方法 使用–foreground选项和超时: timeout --foreground 12s tail -f access.log | wc -l 按人超时: --foreground when not running timeout dire
我想做一些像超时12s tail -f access.log | wc -l但是我没有看到wc的输出.能做到这一点需要做些什么?

解决方法

使用–foreground选项和超时:

timeout --foreground 12s tail -f access.log | wc -l

按人超时:

--foreground   when not running timeout directly from a shell prompt,allow COMMAND to read from the TTY and get TTY signals;
               in this mode,children of COMMAND will not be timed out

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读