有没有一种简单的方法来创建一个只持续给定壁时间的管道?
我希望能够对在一段时间内写入 STDOUT 的内容(而不是字节或行)进行“快照”。就像是
tail -f /var/log/whatever.log | pipe_for_seconds 10 > ./10_second_sample_of_log
我正在使用 BASH,但如果这在其他一些 shell 中容易得多,我想听听。
shell pipe stdout
pipe ×1
shell ×1
stdout ×1