因工作需要自己写的bash脚本
传入多个参数依次修改文件!分享出来供大家参考!
实例脚本:br/>#!/bin/bash
arg=([email protected])
n=0
m=0
sad=ls /usr/local/conf | grep test | sort
smile=ls /usr/local | grep test | sort
for slt in $smile
do
sed -i "s/.serverId./\t‘serverId‘ => ‘3${arg[$n]}‘,/g" /usr/local/${slt}
n=$[$n+1]
done
for sss in $sad
do
sed -i "s/.server_name./\tserver_name ${arg[$m]}/g" /usr/local/conf/$sss
m=$[$m+1]
done
原文地址:https://blog.51cto.com/11801990/2412452
时间: 2024-11-10 14:39:44