前言
需求:交互式修改文件内容
步骤
1.创建文件
echo "jdbc.password=xxxx">login.txt
2.检查文件内容
cat login.txt
#预期结果
jdbc.password=xxxx
3.交互式输入密码
read -p "please input mysql password:" password 假设输入123456, 回车
4.替换文件内容
sed -i "s/xxxx/${password}/g" login.txt
5.检查修改结果
cat login.txt #预期结果 jdbc.password=123456