You are not logged in.

#1 2010-09-23 08:53:57

elflord_woods
Member
Registered: 2010-09-16
Posts: 5

replace coma in text file with newline

hello everyone
i have a text file with email addresses separated by comas
i would like to have each address on a single line
so i would like to replace the coma with a newline

how do i do this ?

please suggest either a perl or python or batch script or whatever that works quick and dirty

thx

Offline

#2 2010-09-23 08:58:52

kazuo
Member
From: São Paulo/Brazil
Registered: 2008-03-18
Posts: 413
Website

Re: replace coma in text file with newline

sed 's/,/\n/g' -i text_file

But, really use google next time....

Offline

#3 2010-09-23 08:59:19

rulex
Member
From: Finland
Registered: 2009-05-20
Posts: 55

Re: replace coma in text file with newline

cat FILE | tr ',' '\n'

Offline

#4 2010-09-23 09:06:31

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: replace coma in text file with newline

kazuo wrote:
sed 's/,/\n/g' -i text_file

But, really use google next time....

It's often sensible to output to a new file the first time a sed script is run, just in case of unexpected results.
If using -i  you can also supply a suufix (eg bak) and it will back the file up first.

Also note, not all versions of sed support -i (though on most Linux distros you should be fine).


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#5 2010-09-23 13:36:39

elflord_woods
Member
Registered: 2010-09-16
Posts: 5

Re: replace coma in text file with newline

beautiful
thanks

Offline

Board footer

Powered by FluxBB