Unfortunately, newlines in sed
are not completely standardized. On MacOS, the following works:
echo "300.000" | sed 's/[.:;,"]/\
&\
/g'
(Yes, those are literal, backslashed newlines inside single quotes.)
On those platforms where \n
works, you could simplify to
echo "300.000" | sed 's/[.:;,"]/\n&\n/g'
If you want to replace all spaces, tr
is a portable solution:
echo "300.000" | sed 's/[.:;,"]/ & /g' | tr ' ' '\012'
A more succinct solution might be to use Perl, which is not standardized at all, but only exists in a single implementation, so effectively works portably wherever Perl is installed:
echo "300.000" | perl -pe 's/[.:;,"]/\n$&\n/g'