linux - 从命名管道收集数据一段时间

标签 linux bash pipe

我想分析来自命名管道的一些数据,例如:

cat trace_pipe | awk '{print $6}' | head -100000 | sort | uniq -c |
  sort -k 1 -nr

此命令将从 trace_pipe 收集前 100k 行数据。有没有办法让我收集 10 秒的数据而不是有限的行数?

最佳答案

您可以使用 timeout 命令,您可能需要拆分命令

timeout 10 cat trace_pipe > trace_pipe.cut
awk '{print $6}' trace_pipe.cut | sort | uniq -c | sort -k 1 -nr

关于linux - 从命名管道收集数据一段时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16073581/

相关文章:

bash - 如何设置 bash 以在按一次 Tab 键时显示自动完成选项?

linux - 使用 Sed 从日志文件中提取 XML 内容并将每个结果转储到不同的文件

linux - Bash - 找到每行的最小数量

python - 从 os.system() 命令运行 "piping"脚本

haskell 管道 : Understanding the logic of the "for equality"

linux - test_venv Python 3.6.1 安装失败

java - 如何防止 Maven 的 spring-boot 插件将静态资源复制到目标?

python - pip安装请求报错TypeError : __init__() got an unexpected keyword argument 'max_retries'

linux - 如何延迟管道 netcat 连接到第一个输入

c++ - 如何在 C++ 中将光标位置设置为行首?