LoginSignup
12
10

More than 5 years have passed since last update.

tail -F して指定した文字がでてきたら終了するシェル芸

Last updated at Posted at 2017-03-28

メモ。kill するしかないよなぁ

FILENAME="test.txt"
KEYWORD="test"

tail -F -n0 "$FILENAME" \
| grep --line-buffered "$KEYWORD" \
| while read l; do pkill -f "tail -F -n0 $FILENAME"; done

追記: コメントで頂きました。sed の q なるほど。

sed "/$KEYWORD/q" <(tail -F -n0 "$FILENAME")
12
10
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
10