sed insert newline character
Is there any way to add a newline character with sed? If not sed, another utility?
I would like to do something like Code:
echo "word1a word2a " | sed 's|a |\n|' |
Hi,
What did you actually try? It does work on my box: Code:
$ echo "word1a word2a " |
Where do you want the newline? Between the words or somewhere else?
|
What is wrong with just doing:
Code:
echo "word1\nword2\n" |
Quote:
|
Hi,
You make it a global search and replace: echo "word1a word2a " | sed 's|a |\n|g' Code:
$ echo "word1a word2a " | sed 's|a |\n|g' |
You need a "g" for it to globally replace the string.
Code:
echo 'word1a word2a ' | sed 's|a |\n|g' Edited: Well, it looks like druuna beat me to it. |
All times are GMT -5. The time now is 03:57 PM. |