Skip to main content
1 of 3
Freddy
  • 26.3k
  • 1
  • 27
  • 64

Using GNU awk, you could use FPAT to split each record into the key-value pairs, loop over the fields and append them to a string. If the string is empty, append the opening ", else ; before each field. In the END section, print the string plus the closing ".

awk -v FPAT='[a-z]=[^;"]+' '{
    for (i=1;i<=NF;i++) s=s (s=="" ? "\"" : "; ") $i
}
END {
    print s "\""
}
' file
Freddy
  • 26.3k
  • 1
  • 27
  • 64