Bash Redirection
Redirections
To redirect a file's contents into a command, try:
: </path/to/file
To redirect a command's STDOUT into a file, try:
: >/path/to/file
If the noclobber shell option is enabled, use >| instead to force overwriting.
Use >> instead to append to a file, as opposed to overwriting.
For details on redirecting with file descriptors, including STDOUT and STDERR, see here.
For details on redirecting with process substitutions, see here.
Here Documents
A here document is an anonymous and transient file that is redirected into a command.
echo <<EOF line one line two line four EOF
To indent the here document with tab characters, use <<-EOF.
Some forms of expansion do not apply to here documents: word splitting, history expansion, and filename expansion. To prevent all forms of expansion from being applied, quote the marker (i.e. "EOF")
Note that the here document marker can be anything, but the common convention is to use EOF.
Here Strings
Here strings are a parallel concept to here documents.
echo <<<foo bar baz
Some forms of expansion do not apply to here strings: word splitting, history expansion, and filename expansion.