Reputation: 821
I am getting an input from a shell script, something like:
USER1_OLD:USER1_NEW,USER2_OLD:USER2_NEW ....
The number of key pairs can vary. I need to get output like:
USER1_OLD,USER2_OLD,......
Upvotes: 0
Views: 52
Reputation: 85815
One way using awk
:
$ ./script.sh | awk '{printf "%s",NR==1?$1:","$1}' FS=: RS=,
USER1_OLD,USER2_OLD
It's not clear if you want a trailing comma, if you do the script can be simpler:
$ ./script.sh | awk '{print $1}' FS=: RS=, ORS=,
USER1_OLD,USER2_OLD,
Upvotes: 2