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

4

1

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

vetri

Posted 2009-10-29T14:34:45.163

Reputation:

Answers

12

# 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

Am.

Posted 2009-10-29T14:34:45.163

Reputation: 1 546

5

$ ./foo >> myoutputfile.txt

Oren Mazor

Posted 2009-10-29T14:34:45.163

Reputation: 151