One of the most common tasks when writing Bash scripts or working on the Linux command line is reading and writing files. Learn how to write text to a file in Bash using the redirection operators and tee command.
Source: LXer – Bash: Write to File