用脚本实现读文件的操作,并重写文件
#!/bin/bash
scrconf=$1
destconf=$2
rm -rf ${destconf}
while read line
do
val=${line%%=*}
if [ "${val}" = "path" ]; then
echo "path=/tmp" >> ${destconf}
elif [ "${val}" = "ssl" ]; then
echo "ssl=/etc/ssl" >> ${destconf}
elif [ "${val}" = "Download" ]; then
echo "Download=/tmp" >> ${destconf}
elif [ "${val}" = "IFA_URL" ]; then
echo "IFA_URL=https://ifa.ihnm.chinamobile.com:8443" >> ${destconf}
else
echo "${line}" >> ${destconf}
fi
done < ${scrconf}
文件格式如下,重写后效果:
sh ./test.sh /data/test/hynet.conf /data/test/hynet.conf1
执行命令时,可以加上后缀: 1>/dev/null 2>&1 清除标准输出打印
NO_STDOUT_DUMP