我有大约 100 个文件,我需要根据 Linux 服务器中不同位置文件中的不同用户更新新密码。
那么,有没有通用的shell脚本可以根据用户名从旧密码更新为新密码。
请找到下面给出的文件内容“Resource driverClassName =“com.mysql.jdbc4.jdbc.sysdert”name =“jdbc/ryr_ined”type =“sql.DataSource”url =“jdbc:mysql:xyz.com:1025/weare”username =“xyz”password =“abcd”autoCommit =“false”maxActive =“20”maxIdle =“10”maxWait =“20000””并且“资源名称=“Tkmool”用户名=“weare”密码=“abcd”maxActive=“20”maxIdle=“10”maxWait=“-1”“
感谢您对此的帮助。
最佳答案
这就是您要找的东西?
read -p "path (eg. *.conf will match a.conf)?" path
read -p "username?" username
read -p "new password?" password
find $path -exec sed -r "s/(username="${username}".*password=)\w*/\1"${password}"/g" \{} >temporaryPasswordFile.tmp \; -exec mv temporaryPasswordFile.tmp \{} \;
要求不存在名为temporaryPasswordFile.tmp 的文件。
关于linux - 需要在文本文件中更新新密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30995933/