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

shell-scriptunix

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

Best Answer

# 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
Related Question