Surround all lines in a text file with quotes ('something') Surround all lines in a text file with quotes ('something') linux linux

Surround all lines in a text file with quotes ('something')


Use sed?

sed -e "s/\(.*\)/'\1'/"

Or, as commented below, if the directories might contain apostrophes (nightmare if they do) use this alternate

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


Using sed:

sed -i "s/^.*$/'&'/g" filename


You can use sed(1) to insert single quotes at the beginning and end of each line in a file as so:

sed -i~ -e "s/^/'/;s/$/'/" the_file