This might seem a little odd, but try:
sed -i '' 's/\\n/\
/g' test1.txt
I.e., use an actual newline instead of \n
.
The explanation is that you have a weird sed
!
For details, see the mac sed manual: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/sed.1.html
In the description of the s
command there, it says:
A line can be split by substituting a newline character into it. To specify
a newline character in the replacement string, precede it with a backslash.
Also, in the description of the -i
option, it says that the extension is not optional, and that if you don't want one you must specify an empty argument. So everything makes sense in the end!