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.
如何在变量名中转义通配符扩展?
CP="lib/*" COMMAND="java $VARIABLES -cp $CP SomeClass" echo $COMMAND
回显该命令总是会导致通配符扩展。
echo "$COMMAND"
使用引号可以防止 glob 被扩展。
顺便说一句,请参阅“我正在尝试将命令放入变量中,但复杂的情况总是失败!”
“我正在尝试将命令放入变量中,但复杂的情况总是失败!”
请改用数组。