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.
有没有办法通过 bash 执行命令获取变量?
例子:
./exec.sh var1 var2
或有论据
./exec.sh -x var1 -y var2
我寻找“在 bash 执行时获取变量”但没有。
正如评论所提到的,$1、$2 等是参数的位置变量。但是还有更多非常有用的,比如 $# 用于传递的参数数量等。更多信息在
http://wiki.bash-hackers.org/syntax/shellvars