It’s Cybersecurity Awareness Month! Join our interactive training session, or learn about security and AI from 1Password experts.
Forum Discussion
adrianbj
5 years agoNew Contributor
anyone have examples of editing existing Vault entries from CLI?
I have several vaults within our company's division where we would like to add more entries for all.
I am looking for a path that I can follow to automate this.
I understand the limitation, but a...
adrianbj
5 years agoNew Contributor
@ag_yaron or @Michael_1P As a follow up question, do either of you know of a way to use jq or any other tool to get the length for a specific array? And is there a way to narrow down a particular index of my array, so that I can append my new fields?
For example, while following the approach above, I have a scenario where my .details json has 4 different members under sections. I was trying to use "sections[].fields" to filter the length so that I could append the new entries to the section. In the screenshot below, you can see 2 of the 4 members under "sections":
This works for me in scenarios where there is one section: jq '.sections[].fields | length' details.json
This returns a single result.
However, in the problematic scenario, I am seeing 4 results, ex:
0
12
0
1
So, looking for a way to get one result, like jq '.sections[1].fields | length' details.json
However, I would like to automate this, so the problem is that the vaults are unique in that some have several sections and some don't.
To modify the json, I am using the following example: _ jq '.sections[].fields['\${arrayLength}'] += {"k":"string","n":"04D8B865E7B04AC0A102E85C2F3A723D","t":"Purpose of the credential","v":"enter text"}' ./Login/\${item_uuid}/details.json > "\$tmp" && mv "\$tmp" ./Login/\${item_uuid}/details.json_
So, I would need a valid array path and length.