问题
How do I escape a wildcard expansion in a variable name?
CP="lib/*"
COMMAND="java $VARIABLES -cp $CP SomeClass"
echo $COMMAND
Echoing the command always causes wildcard expansion.
回答1:
echo "$COMMAND"
Using quotes prevents the glob from being expanded.
By the way, see "I'm trying to put a command in a variable, but the complex cases always fail!"
回答2:
"I'm trying to put a command in a variable, but the complex cases always fail!"
Use an array instead.
来源:https://stackoverflow.com/questions/10888764/how-to-escape-wildcard-expansion-in-a-variable-in-bash