I need to convert a column which is in CSV format to a comma-separated list so that I can use a for
loop on the list and use each parameter.
Here what I have tried:
$ gcloud dns managed-zones list --format='csv(name)' --project 'sandbox-001'
Output:
name
dns1
dns2
dns3
dns4
I need such result: "dns1,dns2,dns3,dns4" so that I can use a for
loop:
x="dns1, dns2, dns3, dns4"
for i in $x:
print $i
done
The paste
command returns me the last line:
$ gcloud dns managed-zones list --format='csv(name)' --project 'sandbox-001' |paste -sd,
,dns4
I would appreciate if someone can help me with this.