Thanks for the reply... One problem with the script...APPLE, ORANGE & GRAPE should come in the 1st line but the script is reading line by line, it should group the various designs under the car brand in single line.
awk '/YEAR/{$1=$1;print}' OFS=", " file | sed 's/\(.*\),\(.*\)/\1\2/'
/YEAR/ -> select lines with "YEAR"
$1=$1 -> reset the field separators (remove double spaces)..
print -> ..and print the line..
OFS=", " -> .. with the new output fieldseparator
sed 's/\(.*\),\(.*\)/\1\2/'
The sed command removes the last comma of the output of the awk command.
\(.*\),\(.\) -> selects two patterns \(.\) of the string, the 1st pattern is the line until the last comma (greedy match) and the 2e pattern the line after the last comma.
\1\2 -> prints the 2 patterns.
---------- Post updated at 14:55 ---------- Previous update was at 14:25 ----------
Sorry, I misread the question...in this case the code shouldn't work.
Did you try the other solutions above?
Difficult to automate this with a bad structured file, you could have more pitfalls in your file...