paste -d, -s filename | sed 's/,/","/g' | sed 's/^/"/' | sed 's/$/"/'
Example:
file1.txt contains:
alpha
bravo
charlie
delta
echo
paste -d, -s file1.txt | sed 's/,/","/g' | sed 's/^/"/' | sed 's/$/"/' > file2.txt
file2.txt contains:
"alpha","bravo","charlie","delta","echo"
Cool! I found the challenge interesting so I came up with one too.
sed -e ‘:a;N;$!ba;s/\n/”,”/g;s/^/”/;s/$/”/’ file2.txt
Ooops .. doesn’t like my formatting:
sed -e ‘:a;N;$!ba;s/\n/”,”/g;s/^/”/;s/$/”/’ file1.txt