split long line on a delimiter

There are a few options:

  • tr : \\n
  • sed 's/:/\n/g' (with GNU sed)
  • awk '{ gsub(":", "\n") } 1'

You can also do this in pure bash:

while IFS=: read -ra line; do
    printf '%s\n' "${line[@]}"
done

If your grep supports -o you can do it like this:

grep -o '[^:]\+'

Or with awk, setting the record separator to ::

awk -v RS=: 1

Or with GNU cut:

cut -d: --output-delimiter=$'\n' -f1-

Edit

As noted by Chris below, this will leave a trailing newline, this can be avoided if your awk supports specifying RS as a regular expression (tested with GNU awk):

awk -v RS='[:\n]' 1

$ line=foo:bar:baz:quux
$ words=$(IFS=:; set -- $line; printf "%s\n" "$@")
$ echo "$words"
foo
bar
baz
quux