I'll preface this with my jq is beginner subpar state. I'm trying to search all my passwords to see what has a TOTP entry on a Windows 10 machine and then tag them so I can easier find them later. I believe I can do the latter based on https://1password.community/discussion/comment/573170#Comment_573170
But I'm struggling a bit to find things that have OTPs. I see there's a field with "one-time password" but I can't seem to figure out the syntax. I think it'd be something along the lines of op list items --vault Private | jq '.[] | select(.details.sections[].fields[].t == \"one-time password\") | .overview.title'
but I get a cannot iterate over null error. If I explicitly define 0 for the sections/fields, it works but no results.
Clearly, I don't understand how to structure the select with arrays What am I not understanding?
Thanks
1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Win10
Sync Type: Not Provided
Comments
Team Member
Hey @linh_nguyen ,
The
op list items
command does not check fields content, but just lists items without reviewing their detailed sections.You'll need to iterate through every item in your vault(s) and return the ones that have a TOTP field with the get command. Here's an example for listing all items, then getting each item separately and searching if it has a TOTP field:
op list items |jq -r '.[].uuid' | op get item - | jq '. | select(.details.sections[].fields[].t == "one-time password") | .overview.title'
I hope that will point you in the right direction
appreciate it! probably can't do what I originally planned as the effort may not be worth it. But this got what I needed!
Team Member
That's great to hear @linh_nguyen! Let us know how it goes
And on behalf of ag_yaron, you are very welcome