Use the $a syntax and sed:
sed -i '$a some text' filename |
-i parameter means in place. To test without changing the original file, remove the -i option. The results will be print on the screen.
A previous post explained how to insert a line anywhere but for completeness. Indeed, with the $a syntax you append content and therefore you can append text after a line. Therefore you cannot append text before the first line. Instead use the i command:
sed -i '1i some text on first line' filename |
Please follow and like us:
i did the command exactly as it said but i got “sed: -e expression #1, character 10: unterminated `s’ command”
Indeed, there was a typo. The ” characters should have been single quote ‘. This is fixed now. Thanks for spotting this.