I track logs through tailf ( tail -f ). For convenience of display, I would like to add an empty line after each line.
For example:
$ tailf /var/log/some.log log1 log2 log3 $ tailf /var/log/some.log | magic log1 log2 log3 Tried through sed in two ways, but I receive the same without changes. The idea is to patch the line break and replace it with two lines. The general syntax is: sed 's/substitute_this/to_this/g'
Method 1: insert a line break as $'\n' .
$ tailf /var/log/some.log | sed "s/$'\n'/test/g" log1 log2 log3 It seems that $'\n' does not match line breaks in my log.
Method 2: insert a line break as a line break when entering the command:
$ tailf /var/log/some.log | sed "s/ > /test/g" sed: -e expression #1, char 2: unterminated `s' command $ tailf /var/log/some.log | sed "s/\ /test/g" sed: -e expression #1, char 0: no previous regular expression If it were a shell script, one could use a hack :
newline=' ' But I want to use it on the go. To make a function or alias is also not suitable, because I work with a large number of hosts and do not have the ability to individually configure .bashrc .
Actually, the question is: what should be in place magic ?
sed "s/$/\n/g"? - BOPOHsed: -e expression #1, char 8: unknown option tos' ` - Nick Volynkin ♦tailf /var/log/apache2/access.log | sed "s/$/\n/g"tailf /var/log/apache2/access.log | sed "s/$/\n/g"- BOPOH$, why does it match as a line break? It is clear that on the right side,\nbecomes a line break. - Nick Volynkin ♦^like$is not a symbol, but a position in the text. The attachment cannot be replaced, but something can be inserted there. Those. replacing$with something, you actually insert this “something” at the end - BOPOH