我正在尝试使用 bash 脚本自动更新软件。当我传递版本号时,例如 7.16.3,我收到以下错误:“)语法错误无效的算术运算符(错误标记是”
read
从命令传递值时,我找不到任何相关的答案。我的代码如下所示:
DATE=`date +'%Y%m%d'`
BSI_SETUP=/opt/bsi/source/setup/elk_${DATE}
OLD_VERSION_FILEBEAT=`/usr/share/filebeat/bin/filebeat version| awk '{print $3 }' 2>/dev/null`
OLD_VERSION_METRICBEAT=`/usr/share/metricbeat/bin/metricbeat version| awk '{print $3 }' 2>/dev/null`
MY_HOME=~
read -p 'Enter filebeat & metricbeat version: ' NEW_VERSION_BEATS
read -p 'Enter CSC environmet: ' CSC_ENV
if [[ ${NEW_VERSION_BEATS} -ne ${OLD_VERSION_FILEBEAT} ]]; then # I get error here
sudo yum install -y $BSI_SETUP/filebeat-*.rpm 2>/dev/null
else
echo "Filebeat is up-to-date"
fi
if [[ ${NEW_VERSION_BEATS} -ne ${OLD_VERSION_METRICBEAT} ]]; then # and here
sudo yum install -y $BSI_SETUP/metricbeat-*.rpm 2>/dev/null
else
echo "Metricbeat is up-to-date"
fi