我有一个包含所有用户的mysql授权的文件。看起来像这样:
GRANT USAGE ON *.* TO 'web_user'@'10.16.%' IDENTIFIED BY PASSWORD '*288A8C32D8C898U779EDA321A6CD6525DB2D3166';
GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON `users`.* TO 'web_user'@'10.16.%';
GRANT SELECT, INSERT, UPDATE, DELETE ON `zip`.* TO 'web_user'@'10.16.%';
GRANT USAGE ON *.* TO 'alarms'@'10.16.%' IDENTIFIED BY PASSWORD '*E8DEF50F129E0DAF1113382944F603677BA11260';
GRANT SELECT, EXECUTE ON `users`.* TO 'alarms'@'10.16.%';
...
...
...
使用sed我需要删除密码。我应该看起来像这样:
GRANT USAGE ON *.* TO 'web_user'@'10.16.%' IDENTIFIED BY PASSWORD
GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON `users`.* TO 'web_user'@'10.16.%';
GRANT SELECT, INSERT, UPDATE, DELETE ON `zip`.* TO 'web_user'@'10.16.%';
GRANT USAGE ON *.* TO 'alarms'@'10.16.%' IDENTIFIED BY PASSWORD
GRANT SELECT, EXECUTE ON `users`.* TO 'alarms'@'10.16.%';
...
...
...
答案 0 :(得分:2)
sed 's/identified by password.*/identified by password/i'
答案 1 :(得分:1)
这应该适合你:
sed 's/\(PASSWORD\).*$/\1/' file
如果您要对此file
进行更改,只需为-i
添加sed