add modify json name attribut script for bitwarden
This commit is contained in:
parent
4a01b25867
commit
67d36b884f
1 changed files with 21 additions and 0 deletions
21
modify_json-bitwarden.sh
Executable file
21
modify_json-bitwarden.sh
Executable 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."
|
Loading…
Reference in a new issue