Reputation: 1879
hello I am working with a file that looks as follows:
AliceBlue
AntiqueWhite
Aqua
Aquamarine
Azure
Beige
Bisque
Black
BlanchedAlmond
Blue
BlueViolet
Brown
I would like to obtain from this one another list with the following structure:
"AliceBlue","AntiqueWhite","Aqua",...,
I order to achieve this I tried:
awk -vORS=, '{ print $1 }' listColors.txt | sed 's/,$/\n/'
And I got:
AliceBlue,AntiqueWhite,...,
I almost achieve what I wanted but I think that I need to build a regular expression to add the double quotes to all the words, I am not an expert on regular expressions, I would like to appreciate any suggestion to complete the task.
Upvotes: 1
Views: 65
Reputation: 785306
Using awk
you can do:
awk -v ORS=, '{$1= "\"" $1 "\""} 1' file; echo
"AliceBlue","AntiqueWhite","Aqua","Aquamarine","Azure","Beige","Bisque","Black","BlanchedAlmond","Blue","BlueViolet","Brown",
Upvotes: 3