Quote:
Originally Posted by Robhogg
Firefox saves daily backups of your bookmarks in json files. ...
|
The
daily part of that is why, not knowing if the OP needs up to the moment data, I didn't mention the JSON.
Perhaps without additional details about what the overall purpose is, of the Command Line based search for keywords, more of an overview of possible general ways to approach it is better.
It may be that doing it from the Command Line is just an Intellectual Exercise, for the fun of it.
Either way whitehunk, you might want to consider the following.
sqlite3 has locking capabilities to try to prevent database corruption. Yet virtually nothing is perfect, which is why I cautioned against using the sqlite3 database used by FF ( Firefox ) , when FF is running. For some details, please see the section on, how to corrupt your database, in the document on sqlite3 locking, at sqlite.org.
There's the JSON approach that, used at a randomly picked time of day, may be out of date. It might produce some garbage output as well, if you happen to catch things just right as FF is writing the JSON.
It's also possible to use FF itself to export up to the moment book marks as HTML, then search through the output file by keyword.
A gawk program such as this:
Code:
/<DT><A HREF="http/ { a_elem_residue = substr( $4 , 9 ) ; quote2_pos = index( a_elem_residue , "\042" ) ; print "TITLE: " $(NF-2) " URI: " substr( a_elem_residue , 1 , quote2_pos - 1 ) }
can grab the Title and Uri from the output HTML file.
In a sense, you can already search for book marks in FF by keyword in some bookmark fields, without an extension. You can also assign tag(s) to book marks, then search for the tags.
If you already have a large number of book marks, you could extend a Command Line approach to searching by keyword, or combination of keywords, to apply tags to large numbers of existing book marks in a single pass, chosen by the keyword search. Then repeat the procedure for each keyword, or combination of keywords. The tags could potentially by applied via sqlite3 when FF is not running.
If you're worried about whether or not extensions can be trusted, I wouldn't go to some web site with which I was unfamiliar, like joe_bobs_evil_extension_site.com , download extensions and then use them. But being a bit careful, and downloading from Mozilla, I've never encountered a deliberately malicious extension.
Finally, if you won't use an extension, or if you want to search in some more complicated fashion than FF ( or perhaps any existing extension ) already allows, if you can write a command line facility to search by keyword, odds are you can add similar functionality to FF, by writing your own extension to FF that searches the way you want.
Hope this helps!