Lets say that you have a file with 1000 lines and you want to add the word start in front of each line and the word end in the end of each line. What can you do?
Let’s assume that the file is named magic.txt the command will be:
sed ‘s/^/start/g;s/$/end/g’ magic.txt
So if you want to add only in front of file use:
sed ‘s/^/start/g’ magic.txt
and if you want to add a word only at the end of the file:
sed ‘s/$/end/g’ magic.txt
Isn’t it simple?