Hi,
I have a comma separated file. I would like to print every alternate columns into a new row.
Example input file:
Name : John, Age : 30, DOB : 30-Oct-2018
Example output:
Name,Age,DOB
John,30,30-Oct-2018
Hi,
I have a comma separated file. I would like to print every alternate columns into a new row.
Example input file:
Name : John, Age : 30, DOB : 30-Oct-2018
Example output:
Name,Age,DOB
John,30,30-Oct-2018
echo 'Name : John, Age : 30, DOB : 30-Oct-2018' | awk -F'[:,]' '{for(i=2;i<=NF;i=i+2) printf("%s%s", $i,(i+2>NF)?ORS:OFS)}' OFS=,
Thanks. It worked. But header is missing
This is left an exercise for the OP.