Do a tail -F until matching a pattern

后端 未结 10 1385
遥遥无期
遥遥无期 2020-11-28 09:21

I want to do a tail -F on a file until matching a pattern. I found a way using awk, but IMHO my command is not really clean. The problem is that I need to d

10条回答
  •  野性不改
    2020-11-28 10:11

    Use tail's --pid option and tail will stop when the shell dies. No need to add extra to the tailed file.

    sh -c 'tail -n +0 --pid=$$ -f /tmp/foo | { sed "/EOF/ q" && kill $$ ;}'
    

提交回复
热议问题