我有一些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