write to a file after piping output from tail -f through to grep

前端 未结 4 651
孤独总比滥情好
孤独总比滥情好 2021-01-05 15:19

I\'m looking to write to a file after piping output from tail -f through to grep. Say,write to a file \"temp\" for all lines with \"Playing:\" within in error_log \"FreeSwit

4条回答
  •  盖世英雄少女心
    2021-01-05 15:58

    -f, --follow[={name|descriptor}]
                  output appended data as the file grows;
    

    It scans the file as it grows. And it is a process with an interval. You can only interrupt it.

    Use parameter:

    -c, --bytes=K
                  output the last K bytes; alternatively, use -c +K to output bytes starting with the Kth of each file  
    

    or

    -n, --lines=K
                  output the last K lines, instead of the last 10; or use -n +K to output lines starting with the Kth
    

    EDIT: as bmk said:

    grep --line-buffered  
    

    think it will help you

提交回复
热议问题