Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a file that I am trying to read by using tail -f. I was wondering if there was a way to have the terminal output an actual line break instead of the \n character.

share|improve this question
As a rule, tail -f will display line breaks as line breaks. You may have an issue with your console settings, if that's what you're seeing. –  Jon Lasser Mar 25 '10 at 21:50
Or he's tailing a file which actually has a literal \n in it. Maybe line breaks were converted to a literal "\n" before being written to a file. –  Josh Mar 26 '10 at 3:09

2 Answers 2

up vote 5 down vote accepted
tail -f file | sed 's/\\n/\n/g'
share|improve this answer
tail -f file | sed 's/\\n/\n/g' –  Vi. Mar 26 '10 at 2:54
Thank you. Fixed. –  Dennis Williamson Mar 26 '10 at 3:54
I would like to add that I found I needed to actually physically enter a line break in my sed command after the back-slash in order to make this work, like so: ~$ tail -f /var/log/apache2/error_log | sed 's/\\n/\ > /g' –  Jon z Dec 20 '11 at 18:46
tail -1 file | awk '{gsub(/\\n/,"")}1'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.