by shigemk2

当面は技術的なことしか書かない

複数ファイルでも tail -f がしたい 僕なりの感想

複数ファイルでも tail -f がしたい - Qiita

この記事から。表題で、複数ファイルでもtail -fがしたいので、どうしたらいいかってところで適当に探していた。

3 Methods To View tail -f output of Multiple Log Files in One Terminal

自作multi-tail.sh

$ vi multi-tail.sh
#!/bin/sh

# When this exits, exit all back ground process also.
trap 'kill $(jobs -p)' EXIT

# iterate through the each given file names,
for file in "$@"
do
    # show tails of each in background.
    tail -f $file &
done

# wait .. until CTRL+C
wait

これを使ってみた雑感だけど、流れの早いログだとどのログが流れているのかわからなくて使いづらかった

普通にtail -f ファイルA ファイルB

上に同じ。

multitail

なるほど、たしかにmultitailは便利だね。