Hi all,
I have a single line output like below
echo $ips
10.26.208.28 10.26.208.26 10.26.208.27
want to convert above single line output as below format. Pls advice how to do ?
10.26.208.28
10.26.208.26
10.26.208.27
Regards
Kannan
Hi all,
I have a single line output like below
echo $ips
10.26.208.28 10.26.208.26 10.26.208.27
want to convert above single line output as below format. Pls advice how to do ?
10.26.208.28
10.26.208.26
10.26.208.27
Regards
Kannan
If the value of the variable already has embedded newlines, then all you have to do is quote the variable. If not, you can use the tr
utility to convert the embedded whitespace to newlines.
Regards,
Alister
echo $ips | tr -s " " "\n"
echo $ips|xargs -n1
Thanks a lot all the reply got it now !!
regards
Kannan
Here's a way using pure shell builtins:
printf "%s\n" $ips
echo $ip | perl -pe 's/ /\n/g'
echo $ip | sed 's/ /\n/g'