Wednesday, 14 August 2013

Using sed to split a string with a delimiter

Using sed to split a string with a delimiter

I have a string in the following format:
string1:string2:string3:string4:string5
I'm trying to use sed to split the string on : and print each sub-string
on a new line. Here is what I'm doing:
cat ~/Desktop/myfile.txt | sed s/:/\\n/
This prints:
string1
string2:string3:string4:string5
How can I get it to split on each delimiter?

No comments:

Post a Comment