たとえば、wget が終了したときにどうすれば tail を kill できますか。
#!/bin/bash
wget http://en.wikipedia.org/wiki/File:Example.jpg &
tail -f example.log
おそらくこれはより良いです-私はそれをテストしていません:
#!/bin/bash
LOGFILE=example.log
> $LOGFILE # truncate log file so tail begins reading at the beginning
tail -f $LOGFILE &
# launch tail and background it
PID=$!
# record the pid of the last command - in this case tail
wget --output-file=$LOGFILE http://en.wikipedia.org/wiki/File:Example.jpg
kill $PID
#launch wget and when finished kill program (tail) with PID
これは、バックグラウンドではテールがコンソールに出力を表示するという事実に基づいています。ただし、これは簡単にリダイレクトできません。