0

複数の if-else を使用している場合でも、構文エラーが発生します。助けてください

stats=$(rpm -qa | grep MySQL)
set -f  # turn off globbing, so as not to expand wildcards
arr=($(echo "$stats" | sed 's/,/ /g'))
if [[ "${arr[0]}" == "MySQL-server-5.6.11-2.rhel5" ]] && [[ "${arr[1]}" == "MySQL-client-5.6.5_m8-1.rhel5" ]]; then
        rpm -e MySQL-server-5.6.11-2.rhel5
        rpm -e MySQL-client-5.6.5_m8-1.rhel5
        echo "MySQL Successfully Removed";
elif [ "${arr[0]}" == "MySQL-server-5.6.11-2.rhel5" ]; then
         rpm -e MySQL-server-5.6.11-2.rhel5

elif [ "${arr[1]}" == "MySQL-client-5.6.5_m8-1.rhel5" ]; then
         rpm -e "MySQL-client-5.6.5_m8-1.rhel5
else
        echo "Done"

fi
4

1 に答える 1

0

2 番目の条件にスペースを追加する必要があります。

[["${arr[1]}" == "MySQL-client-5.6.5_m8-1.rhel5"]]
  ^                                            ^
   \                                          /
    - here                              here -

そうです

[[ "${arr[1]}" == "MySQL-client-5.6.5_m8-1.rhel5" ]]
于 2013-07-01T08:14:45.237 に答える