I'm tailing logs and they output
instead of newlines.
I thought I'd pipe the tail
to awk
and do a simple replace, however I cannot seem to escape the newline in the regex. Here I'm demonstrating my problem with cat
instead of tail
:
test.txt
:
John
Doe
Sara
Connor
cat test.txt | awk -F'\n' '{ print $1 "
" $2 }'
Desired output:
John
Doe
Sara
Connor
Actual output:
John
Doe
Sara
Connor
So it looks like \n
does not match the
between the first and last names in test.txt but instead the newline at the end of each line.
It looks like \n
is not the right way of escaping in the terminal right? This way of escaping works fine in e.g. Sublime Text:
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…