From 67d36b884f41341685d4350a68d2c01d4d1651cb Mon Sep 17 00:00:00 2001 From: Simon Rieger Date: Thu, 18 Jul 2024 13:13:07 +0200 Subject: [PATCH] add modify json name attribut script for bitwarden --- modify_json-bitwarden.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 modify_json-bitwarden.sh diff --git a/modify_json-bitwarden.sh b/modify_json-bitwarden.sh new file mode 100755 index 0000000..85fff70 --- /dev/null +++ b/modify_json-bitwarden.sh @@ -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."