我试图让这段代码接受用户给定的 4 值或“/”来接受默认值。
#!/bin/bash
$komp=1
while [ ${#nbh[@]} -ne `expr 4 \* $komp` || ${nbh[0]} -ne "/" ]
do
echo "Enter 4 element or / to accept default"
read -a nbh
if [ ${#nbh[@]} -ne `expr 4 \* $komp` || ${nbh[0]} -ne "/" ]
then
echo "Wrong!!"
else
if [ nbh -eq "/" ]
then
declare -a nbh=('1' '0' '1' '1')
fi
fi
done
在目前的情况下,它给出了错误:
./mini.sh: line 3: [: missing `]'
./mini.sh: line 3: -ne: command not found
请帮忙。