[英]linux using watch command with a seperator
我有3個文件,我想使用“ watch”命令觀看這些文件的更改。 但是這3個文件有很多行,我只想查看帶有“ tail”的最后3行。 這里沒有問題。 我可以為此使用此命令:
watch 'tail -3 file1; tail-3 file2; tail -3 file3'
此命令給我這樣的輸出:
Every 2.0s: tail -3 file1; tail -3 file2; tail -3 file3
file1 row9
file1 row10
file1 row11
file2 row9
file2 row10
file2 row11
file3 row9
file3 row10
file3 row11
我想用任何分隔符分隔這些行,並看到如下結果:
Every 2.0s: tail -3 file1; tail -3 file2; tail -3 file3
file1 row9
file1 row10
file1 row11
-----
file2 row9
file2 row10
file2 row11
-----
file3 row9
file3 row10
file3 row11
分隔符無關緊要。 我只想看看結果是分開的。
我將文件放在這樣的循環中:
watch 'for file in {file1,file2,file3}; do tail -v -n3 $file; echo '----'; done'
輸出:
==> file1 <==
row9
row10
row11
-----
==> file2 <==
row9
row10
row11
-----
==> file3 <==
row9
row10
row11
-----
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.