我有一些shell命令。我想將輸出寫入標準輸出並將其保存到變量中。 我想用一個命令來解決它。 我試過這些東西。重定向命令輸出到變量和標準輸出ksh
ls > $VAR # redirects the output to file which name is stored in $VAR
ls | tee -a $VAR # writes to standard output as well as in file which name is stored in $VAR
VAR=`ls` # output into $VAR, but it is not sent to standard output
VAR=`ls`;echo $VAR # ok, it works but these are two commands
任何想法?
只是好奇1線的限制。這使得我不僅僅是系統目標用戶的根源。我無法弄清楚爲什麼你有這個限制。無論如何,我已經發布給你一個「你自己」的答案。 – erm3nda