2014-12-27 119 views

回答

0

要重定向输入和输出,只需使用这两种重定向:

command <inputfile> outputfile 

如果该命令不从标准输入读取,则输入重定向不会有任何效果。例如,ls不使用它的输入,它只是处理命令行参数。

1

可以使用script命令

输入

$ script 
Script started, file is typescript 
sh-4.1$ ls 
bar.txt baz.txt foo.txt typescript 
sh-4.1$ exit 
exit 
Script done, file is typescript 

输出

$ cat typescript 
Script started on Sat Dec 27 13:49:33 2014 
sh-4.1$ ls 
bar.txt baz.txt foo.txt typescript 
sh-4.1$ exit 
exit 

Script done on Sat Dec 27 13:49:40 2014 

explainshell.com - script

相关问题