add modify json name attribut script for bitwarden

This commit is contained in:
Simon Rieger 2024-07-18 13:13:07 +02:00
parent 4a01b25867
commit 67d36b884f

21
modify_json-bitwarden.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/bash
# Read the JSON file
json_file="$1"
json_content=$(cat "$json_file")
# Use jq to modify the JSON
modified_json=$(echo "$json_content" | jq '
.items[] |= (
if .login.uris and (.login.uris | length > 0) then
.name += " " + (.login.uris[0].uri | sub("^http://"; ""))
else
.
end
)
')
# Write the modified JSON back to the file
echo "$modified_json" > "${json_file}.new"
echo "JSON file has been updated."