How to enclose every line in a file in double quotes with sed? How to enclose every line in a file in double quotes with sed? windows windows

How to enclose every line in a file in double quotes with sed?


here it is

sed 's/\(.*\)/"\1"/g'


shorter

sed 's/.*/"&"/'

without spaces

sed 's/ *\(.*\) *$/"\1"/'

skip empty lines

sed '/^ *$/d;s/.*/"&"/'


You almost got it right. Try this slightly modified version:

sed 's/^.*$/"&"/g' file.txt