同时tail多个文件
普通的tail命令只能查看一个文件的输出,保存如下内容为multail.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#!/bin/sh function clean() { #echo $@; #for file in "$@"; do ps -ef|grep $file|grep -v grep|awk '{print $2}'|xargs kill -9; done jobs -p|xargs kill -9 } files=$@ # When this exits, exit all back ground process also. #trap "ps -ef|grep tail|grep -v grep|awk '{print "'$2'"}'|xargs kill -9" EXIT trap "clean $files " 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 |
使用方法:./multail.sh 文件1名 文件2名 ... 文件n名
结束方法: CTRL+C
3 Methods To View tail -f output of Multiple Log Files in One Terminal
multitail直接搞定
是可以,可是某些老机器,比如solaris没有同时自己也不能装的就悲催了。