Linux shell修改init文件方法

版权声明:本文为博主原创文章,转载请注明出处 https://blog.csdn.net/sophies671207/article/details/84670877

参考 https://blog.csdn.net/wanxiaoderen/article/details/82388091
awk方法读取功能为:

`awk -F '=' '/‘$Section’/{a=1}a==1&&$1~/'$Key'/{print $2;exit}' $Configfile 

awk方法读取和写入功能为

awk -F '=' "/\[${section}\]/{a=1}a==1" ${iniFile}|sed -e '1d' -e '/^$/d' -e '/^\[.*\]/,$d' -e "/^${option}=.*/!d" -e "s/^${option}=//"
# awk 找出section 之后的内容
# sed 条件1:去除第一行 条件2:去除空行 条件3:去除其他section的内容 条件4:去除不匹配${key}=的行 条件5:将${key}=字符剔除

set -x
在shell中添加这个命令,可以看详细的执行过程

猜你喜欢

转载自blog.csdn.net/sophies671207/article/details/84670877