Hi,
if I have a string delimited by commas how can I put each character on a new line followed by a carriage return, and output this to a filee.g
from:
s,t,r,i,n,g
to
s
t
r
i
n
g
thanks you
Hi,
if I have a string delimited by commas how can I put each character on a new line followed by a carriage return, and output this to a filee.g
from:
s,t,r,i,n,g
to
s
t
r
i
n
g
thanks you
echo "s,t,r,i,n,g" | tr ',' '\n'
>echo s,t,r,i,n,g | gawk 'BEGIN {RS=","}{print $1}'
s
t
r
i
n
g
I would use sed, like this:
s/,/\
/g
This simply uses a substitution command to replace each comma with a newline. You would have to store the string in a file first, then feed the file into the sed script, like this:
sed -f sedscript file
Then just delete the file when you're done with it.