exec 和tailf的解释
exec 不会创建子进程,在当前shell执行命令,执行完后,就退出了
tailf 可以持续追加文件内容
命令展示如下:
cat /tmp/tmp.log
test1
test23445
hello world
nihao
cat ./exec.sh
exec </tmp/tmp.log
while read line;do
echo "$line"
done
执行结果如下:
[7 :::: root@localhost::::: /tmp]# >>>sh exec.sh
test1
test23445
hello world
nihao
tailf 持续读取文件内容
cat tailf.sh
tailf /tmp/tmp.log |while read line;do
echo $line
done
执行结果如下:(持续在监听文件内容)
[9 :::: root@localhost::::: /tmp]# >>>sh tailf.sh
test1
test23445
hello world
nihao
————————# 持续等待后续内容