Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

migrated from stackoverflow.com Oct 29 '09 at 14:37

This question came from our site for professional and enthusiast programmers.

2 Answers 2

# 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
share|improve this answer
$ ./foo >> myoutputfile.txt
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.