Operating System - HP-UX
1752777 Members
6063 Online
108789 Solutions
New Discussion юеВ

Re: insert newline with sed

 
SOLVED
Go to solution
Pieter_5
Advisor

insert newline with sed

Hi,

I have the following output.

aa bb cc. I want to insert newlines at the spaces. So that the output will be
aa
bb
cc

I tried it with sed however it doesn't work.
4 REPLIES 4
Jean-Luc Oudart
Honored Contributor
Solution

Re: insert newline with sed

echo "aa bb cc" | tr " " "\n"

Regards
Jean-Luc
fiat lux
Bharat Katkar
Honored Contributor

Re: insert newline with sed

Hi,
One more way of doing it is:

for i in `cat filename`
do
echo $i
done

Regards,

ps.. Back quotes used in first statement.
You need to know a lot to actually know how little you know
Georg Tresselt
Honored Contributor

Re: insert newline with sed

What did you try with sed ? Was it similar to this:

sed 's/ /\n/'
http://www.tresselt.eu
Geoff Wild
Honored Contributor

Re: insert newline with sed

Try this:

cat yourfile | sed 's/ /&=/g' | tr "=" "\n"

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.