It's very convenient to monitor logs using less command - you see what is going with your system as it happening. The bad thing is that my logs are optimized for grep tool: each atomic action is always printed in a single line (I can easily lookup for actions performed by certain user then).

Still, actions contain incoming messages, which are more user-friendly if being printed multiline. If I want to filter log "offline", it's easy:

cat ./log/system.log | tail -50 | tr '\\n' '\n'

Can I do those replacements "online"? What I mean is that replacements are done as new text being appended to log and shown to the screen like less + G.

  • Note that tr '\\n' '\n' would transliterate both backslash and n characters to a newline one with haft tr implementations, and backslashes only in the other half. That is not substituting \n with a newline character. Mar 26, 2015 at 9:43

2 Answers 2


You can if you drop the redundant cat command.

tail -f ./log/system.log | tr '\\n' '\n'

or putting a filter in there:

tail -f ./log/system.log | grep [whatever] | tr '\\n' '\n'
  • 1
    grep usually needs the --line-buffered parameter when taking a stream as input.
    – wullxz
    Feb 1, 2018 at 14:21

Have you tried replacing tail -50 with tail -f ?

tail -fn50 ./log/system.log | sed 's/\\n/\

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .