Search code examples
greppipetailxmllint

tail pipe grep pipe xmllint not working


I'm trying to get the below command working but no o/p is getting printed:

tail -f mylog.log | grep --line-buffered -Eo '<S:Envelope .+Envelope>' | xmllint --format --recover -

However, if I grep the same pattern from a file, and pipe it to xmllint, it works:

grep --line-buffered -Eo '<S:Envelope .+Envelope>' tmp.xml | xmllint --format --recover -

What am I missing in the first command?


Solution

  • Can you try this (untested):

    tail -f mylog.log | grep -Eo '<S:Envelope .+Envelope>' | while read line; do
        echo $line | xmllint --format --recover -
    done
    

    (that is under the hypothesis that xmllint does not find EOF and as such is still waiting for input)