There are lots of ways to add text to a file, the simplest of which don't require any external commands, just a '>>
A slightly more complex one, which can be used to add multiple lines at once, is a here document.
cat >>/etc/my.cnf <<"ENDSTRING"
All of the text between the ENDSTRINGS will be directed as-is to the file. The quote marks around the first ENDSTRING keep any variable names or other patterns from expanding. Remove them if you want substitutions to be done before printing.
For more advanced editing work inside scripts, such as inserting lines at the beginning of a file, you do generally have to use an external command. But instead of sed
, consider using ed
(also read the info page)