Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们可以将上一个命令的状态重定向到另一个变量吗? 比如:echo hello s=echo $?
您可以分配它:
echo hello myVariable=$? echo "Previous echo exit code is $myVariable"
$?和其他变量一样,它只是一个变量——唯一的魔力在于它是如何“自动”设置的。
$?