I find that
\n doesn't work in sed under Mac OS X.
Specifically, say I want to break the words separated by a single space into lines:
# input foo bar
echo "foo bar" | sed 's/ /\n/'
But the result is stupid, the
\n is not escaped!
After I consulted to google, I found a workaround:
echo 'foo bar' | sed -e 's/ /\'$'\n/g'
After reading the article, I still cannot understand what
Can some one explain it to me, or if there is any other way to do it? Thanks!