【问题标题】:A simple way to add pipes to tee-d file将管道添加到 tee-d 文件的简单方法
【发布时间】:2011-08-30 07:35:33
【问题描述】:

我正在尝试使用后处理来记录命令的输出以进行清理
(例如在将命令输出到屏幕时将 ansi 转义码删除到文件中)
(命令是 minicom,除了其他功能外,它还充当终端)。
目前我有以下但它不起作用(似乎阻塞)。

rm "${fifo}"
mkfifo "${fifo}"
cat "${fifo}"|filter_1 >"${log_file}" &
command |tee "${fifo}"

附言

command | tee "${log_file}"

工作正常

【问题讨论】:

  • 查看您的系统是否有可用的unbuffer 命令。您可能需要尝试查看哪些生成命令必须是unbuffered。祝你好运。

标签: shell named-pipes tee


【解决方案1】:

除了unbuffer,你可以试试

{ command ; printf "\n" ; } | tee "${log_file}"

我希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多