How can I take the output of a shell script and place it in a file on the command line?

How can I take the output of a shell script and place it in a file on the command line?


Solution 1:

# write to file
sh myscript > out.txt
# append to file
sh myscript >> out.txt
# write both output and stderr to file
sh myscript 2&1>> out.txt

Solution 2:

$ ./foo >> myoutputfile.txt