2014-12-27 118 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

相關問題