![tail -f, マルチ sed [重複]](https://linux33.com/image/226799/tail%20-f%2C%20%E3%83%9E%E3%83%AB%E3%83%81%20sed%20%5B%E9%87%8D%E8%A4%87%5D.png)
私はできます。
tail -vf -c5 thefile \
| cat -n \
| sed -E 's/a/b/g' \
;
ただし、次の出力はありません。
tail -vf -c5 thefile \
| cat -n \
| sed -E 's/a/b/g' \
| sed -E 's/f/F/g' \
;
なぜ?
答え1
sed
出力をバッファリングします。バッファをより積極的にフラッシュするには、この-u
オプション(存在する場合はGNU sed)を使用します。
stdbuf
バッファリング動作を変更するツールを使用することもできます。
tail -vf -c5 thefile | cat -n | stdbuf -oL sed -E 's/a/b/g' | sed -E 's/f/F/g'