linux sed 批量替换文件内容 包含变量 批量创建用户并设置密码

循环替换文件的字符串,可以使用变量

#!/bin/bash

list = "001 002 003 004 0005"

for i in $list 

do 

sed -i "s/hello/world/" think_${i}.conf

sed -i "s/wusi/student${i}/" think_${i}.conf

done


以下是创建给定用户名:
首先得给出给定用户名,并逐个创建
for user in {u1,u2,u3,u4};这句代码说明给定用户名在{u1,u2,u3,u4}这个数组中;通过for循环逐个取出

do
useradd $user//添加给定user
echo "123456" | passwd --stdin $user;//设置密码
done

发布了172 篇原创文章 · 获赞 45 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/fish_study_csdn/article/details/102663691
今日推荐