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.
2 Answers
tail -f file | sed 's/\\n/\n/g'
-
2I 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'
– jrzDec 20, 2011 at 18:46 -
Does anyone know of a way to achieve the same thing for multitail? Here's a question: unix.stackexchange.com/questions/239774/…– fraxtureOct 30, 2015 at 14:17
-
-
1@Kdansky: You didn't show how you defined the alias or what kind of problem you're having so I can only guess. One problem you may be having is with quoting. An extra backslash may help:
alias forward="tail -f file | sed 's/\\\n/\n/g'"
. If you want to be able to specify the filename as an argument, you should use a function instead of an alias:forward () { tail -f "$@" | sed 's/\\n/\n/g'; }
Dec 8, 2015 at 17:19
grc --colour=on tail -f file | sed 's/\\n/\n░░░░/g