Configuration file as follows:
#Created by JInto - www.guh-software.de #Tue Aug 28 22:20:17 GMT+08:00 2018 aas_amountuser_switch=1 aas_fleet_switch=1 aas_usertokenproct_switch=1 aas_usertokenproct_num=5 aas_devtokenproct_switch=1
......
Read the script as follows:
# /bin/bash configuration_file_path="/opt/some_path/common-conf" current_value=`grep 'aas_amountuser_switch' ${configuration_file_path}/uiConfig.properties | cut -d = -f2 | sed 's/\r//'` echo "$current_value" if [ "$current_value" = "0" ]; then sed -i 's/aas_amountuser_switch=0/aas_amountuser_switch=1/' ${configuration_file_path}/uiConfig.properties echo "modify uiConfig.properties.aas_amountuser_switch success" else echo "modify uiConfig.properties.aas_amountuser_switch error" exit be
note:
At the end of the file in linux there are characters '\ r', need to pay attention to remove line breaks
This small point is not easy to find, so do not see the problem in the script, they can open the debug shell, it is easy to locate out as follows:
sh -x test.sh