Invalid arithmetic operator (error token is " 7.16.3 when passing float from read command
1
vote
1
answer
1616
views
I am trying to automate software update with bash script. When I am passing version number e.g 7.16.3 I get following error: ") Syntax error Invalid arithmetic operator (error token is "
I could not find any answer which related when passing value from
read
command. My code look like below:
#!/bin/bash
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
Asked by codehunter-py
(25 rep)
Jan 25, 2022, 04:01 PM
Last activity: Jan 25, 2022, 05:11 PM
Last activity: Jan 25, 2022, 05:11 PM