題 如何獲取shell腳本的輸出並將其放在命令行的文件中?


如何獲取shell腳本的輸出並將其放在命令行的文件中?


4
2017-10-29 14:34


起源




答案:


# 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

12
2017-10-29 14:37





$ ./foo >> myoutputfile.txt

5
2017-10-29 14:35