Like the title states, I would like to remove all keychain items with the same label. Here is how I am able to one at a time:
security delete-generic-password -l Wired 802.1X
A command I found on this forum uses an AWK command but im stuck there. Here is what I tried:
loggedInUser=$( ls -l /dev/console | awk '{print $3}' )
keychainItem=$( security dump-keychain /Library/Keychains/system.keychain | grep 'Wired 802.1X' | awk -F'["|"]' '/blob/{print $2}' )
security delete-generic-password /Library/Keychains/system.keychain -l "$keychainItem"
With output:
keychain: "/Library/Keychains/System.keychain"
version: 256
class: "genp"
attributes:
0x00000007 <blob>="Wired 802.1X"
0x00000008 <blob>=<NULL>
"acct"<blob>=<NULL>
"cdat"<timedate>=0x32303135303731333132333830365A00 "20150713123806Z00"
"crtr"<uint32>=<NULL>
"cusi"<sint32>=<NULL>
"desc"<blob>="802.1X Password"
"gena"<blob>=<NULL>
"icmt"<blob>=<NULL>
"invi"<sint32>=<NULL>
"mdat"<timedate>=0x32303135303731333132333830365A00 "20150713123806Z00"
"nega"<sint32>=<NULL>
"prot"<blob>=<NULL>
"scrp"<sint32>=<NULL>
"svce"<blob>="com.apple.network.eap.system.item.profileid.8CBE717B-BC16-4DCF-AC34-5E329FB6C337"
"type"<uint32>=<NULL>
password has been deleted.