Bash 如何使用read命令检索*literal?
我有一个接收用户输入的脚本。我想要检索的一个可能值是literalBash 如何使用read命令检索*literal?,bash,Bash,我有一个接收用户输入的脚本。我想要检索的一个可能值是literal*。shell似乎正在拦截它并执行它,所以我得到了所有文件名的列表 while read -p "Enter operand: " operandTwo echo "Argument: $operandTwo" echo "Argument: $(echo $operandTwo)" [ $oper
*
。shell似乎正在拦截它并执行它,所以我得到了所有文件名的列表
while read -p "Enter operand: " operandTwo
echo "Argument: $operandTwo"
echo "Argument: $(echo $operandTwo)"
[ $operandTwo != X ]
echo "Result: $?"
do...
这是输出:
Argument: *
Argument: File1 File2 File3
./script: line 20: [: too many arguments
Result: 2
这里是否比较了File1 File2 File3
和X
?如何在*
和X
之间进行比较?运行脚本并遵循其建议。tldr$(echo$operatortwo)
是多余的,应该引用变量扩展