Unix Ninja - Use SED to wrap line

Posted at

echo 'hello' | sed -e 's@^\(.*\)$@\"\1\"@g'

output: "hello"

notice the @ separator replacing the \\ or / separator you most probably use, sed actually does not specify the mandatory separator use, so along you keep the rules, every "outside of the A-B-C" character would work just fine..
also, it which helps to make the the entire thing more nice and organised :)

naturally file processing would be a little different,
by downloading the GNU parallel or using the pre-"built" parallel perl script I've already made (for people that the word "compile" makes them a little unease)

cat <your_file_name> | parallel --pipe sed -e 's@^\(.*\)$@\"\1\"@g' > output.txt

you can specify -k if you want the output to be same order.. (will make things slower..)
cat <your_file_name> | parallel --pipe -k sed -e 's@^\(.*\)$@\"\1\"@g' > output.txt

let's leave that -k switch outside for now,
and speed up stuff a little by pre-specifying that you won't use anything COOLER THAN Unicode ;)

LC_ALL=C cat <your_file_name> | LC_ALL=C parallel --pipe sed -e 's@^\(.*\)$@\"\1\"@g' > output.txt

nice little trick isn't?