bashshellname-value

Need to manipulate string data using bash


I have data being displayed on the console in the following format:

 "name1",
 "value1",
 "name2",
 "value2",
 "name3",
 "value3",
 ...
 ...

I need to somehow manipulate this output so that it will be displayed in the following format:

 name1 : value1
 name2 : value2
 name3 : value3
 ...
 ...

I'm not very good with shell scripting but I know my options are sed, tr, or awk (or a combination of the aforementioned). I just can't figure out how to accomplish what it is I need here. Thanks in advance!


Solution

  • Pipe it into:

     | sed 's/^ *"\|", *$//g' | paste -d: - -
    

    sed to remove the quotes, paste to join 2 consecutive lines together with a colon.