There is another question which is nearly the same, but none of the suggestions from its answer works for me: Piping tail -f into awk
I'm trying to tail -f a logfile but want to replace \r with \n before displaying it, so that the terminal doesn't overwrite itself but instead allows me to scroll through the output.
this works as suspected:
tail -f -c 1000 "mycustom.log"
and this also:
tail -c 1000 "mycustom.log" | mawk 'gsub("\r","\n")'
none of those three however ever print anything to my console:
tail -f -c 1000 "mycustom.log" | mawk 'gsub("\r","\n")' stdbuf -o0 tail -f -c 1000 "mycustom.log" | mawk 'gsub("\r","\n")' unbuffer tail -f -c 1000 "mycustom.log" | mawk 'gsub("\r","\n")'
unbuffer to be known to my system I had to install the package
mawk doesn't seem to make a difference. I've also written a
which behaves the same for me.
I've also found this question:
But the sed -u parameter doesn't change anything for me, and the $'..' construct is identified as syntax error by my
sed - changing it to \$'...' does run but with tail -f piping to it doesn't ever print anything just like everything else I tried.
Is there anything else I could try? Is the problem that I use a global command in sed / awk? Or maybe is the problem that the original stream produced by
tail -f is only "one line" since there are no \n in it? Is there some way to make sed or awk process smaller chunks than line by line?
Is there an alternative to replace all \r with \n that might work with