0

Is it possible to parse Chrome bookmarks with jq in one line? (for csv output)

With jq '.roots.other.children[]' Bookmarks I get separate lines

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
rei.75
  • 11
  • 1

1 Answers1

0

The Chrome bookmark format is not "flat" so it's not obvious what CSV output you want, but starting with .roots.other.children[] as you suggest, here's a start:

jq -r '.roots.other.children[]
       | [.date_added,.id,.name,.sync_transaction_version,.type,.url,
          (.meta_info|tostring)]
       | @csv' 

Notice how tostring is used here to "flatten" .meta_info. Notice also that the fields of interest have been specified explicitly -- this is to guard against the possibility that their ordering may not always be uniform within the bookmarks file.

peak
  • 105,803
  • 17
  • 152
  • 177