#update /usr/etc/servercnfg.xml if [ -d "/usr/etc" ];then echo "update /usr/etc/servercnfg.xml">>$logfile #插入日志 sed -i 's!<cc1path>/usr/lib</cc1path>!<cc1path>/home/eduyun/eduyun/webapps/ROOT/WEB-INF/classes/libso/centercontrol/linux/x86</cc1path>!g' /usr/etc/servercnfg.xml #替换文本,用!做分隔符 fi #update /etc/environment if [ -d "/etc" ];then echo "update /etc/environment">>$logfile sed -i 's!/convert/linux!/centercontrol/linux/x86!g' /etc/environment if [ ! `grep "RECSVR_APP_PATH" /etc/environment` ];then echo 'RECSVR_APP_PATH="/home/eduyun/eduyun/webapps/ROOT/WEB-INF/classes/libso/centercontrol/linux/x86"'>>/etc/environment #判断文本是否存在,不存在则添加文本 fi fi
添加判断还可以写成
if cat /etc/environment | grep /home/eduyun/eduyun/webapps/ROOT/WEB-INF/classes/libso/convert/linux >/dev/null; then echo "LD_LIBRARY_PATH is setted!" else echo "LD_LIBRARY_PATH="/home/eduyun/eduyun/webapps/ROOT/WEB-INF/classes/libso/convert/linux"" >> /etc/environment fi