Batch update Apple Keychain passwords using terminal I have 41 webform password items stored in Keychain.  Each item has the same password (since each of them is a different wifi router in our building).

Every few months, I need to update all of these items to reflect the new password set up our sys admin.  Is there a quick terminal script that I can use to batch update the password of any item whose name contains "10.18.124." from "oldpw" to "newpw"?
This should be possible with security(1).

The command should like something like this:

security add-generic-password -a 10.18.124.1 -w "newpw" -j "Password Updated 2017-05-17 12:04" -U



-a Specify account name (required)
-w Specify password to be added
-j Specify comment string (optional)
-U Update item if it already exists


I don't think there is a "contains" feature so you maybe have to loop this.