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? To split a string with a delimiter with GNU sed you say: sed 's/delimiter/\n/g' # GNU sed For example, to split using : as a delimiter: $ sed 's/:/\n/g' <<< "he:llo:you" he llo you Or with a non-GNU sed: $ sed $'s/:/\\\n/g' <<< "he:llo:you" he llo you In this