linux - 需要在文本文件中更新新密码

标签 linux shell

我有大约 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/

相关文章:

linux - Windows 10 上的 Ubuntu 上的 Bash 是否支持 USB?

linux - nohup 错误没有那个文件或目录

string - Bash:用空字符串替换子字符串

linux - 如何从 “permission denied” 中排除所有 “grep” 结果行?

linux - 查找文件删除的原因

php - 安全地允许通过 MIME TYPES/fil 上传网络字体(ttf、eot、svg、woff、otf)

linux - bash 合并文件中的行

linux - tar 文件,包括没有 sibling 的目录

linux - Grep 返回 ace 序列而不是我期望的结果

bash - 从 Curl 请求中获取状态码和响应体