Adding words to beginning of lines

I have a file that contains a great number of lines, let's say 183 lines, and I want to add: echo " to the beginning of each line. What is the easiest way to do it?

Tx

I would use sed for that purpose, remember to escape the "

 awk '{print "echo \""$0}' infile

or

 sed 's/^/echo "/' infile
cat filename.txt  | perl -ne 'print "echo " . $_' > output.txt

Another one:

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

Regards

Thanks!

This command works: sed 's/.*/echo "&"/'

What if I want at the same time to add something to the end of each line.
i.e echo "unixtest=test" >> firsttest

what would the command be to add the >> firsttest to teh end of each line

sed 's/.*$/& >> firsttest/' file

What have you tried? Considering you have the basic layout there, you might want to try modifying it slightly and seeing if it works. That will earn you a lot more respect. Perhaps more importantly, you could actually learn something which will help you in the future.

ShawnMilo

...combine both seds into one single command.

sed 's/^.*$/echo "&" >> firsttest/' file

Great!!

Thanks!