In Bash you can easily redirect a string into a file with bash like this
echo "This is my string" > filename
A single >
will replace the contents, >>
will append the string to the end of the file.
For more information have a look at the bash manual regarding Redirection.