如何获取 shell 脚本的输出并将其放在命令行上的文件中?
答案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
答案2
$ ./foo >> myoutputfile.txt
如何获取 shell 脚本的输出并将其放在命令行上的文件中?
# 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
$ ./foo >> myoutputfile.txt