your ODF file (“.odt”, “.ods”, …) and its “modified” timestamp

Your “.odt” (or “.ods”) file is a ZIP file with a meta.xml inside:

$ unzip -l YOUR.ods
…
… meta.xml
…

This is a convenient way to extract meta.xml to STDOUT:

$ unzip -p YOUR.ods meta.xml
…

This is how to get the XML reformatted using xmlstartlet:

$ unzip -p YOUR.ods meta.xml | xml fo

This command line shows you the possible XPath expressions:

$ unzip -p YOUR.ods meta.xml | xml el
…
office:document-meta/office:meta/dc:date
…

How to extract “modified” to STDOUT?

$ unzip -p YOUR.ods meta.xml | xml sel --template --value-of office:document-meta/office:meta/dc:date

And how to extract the timestamp w/o anything but decimal digits?

$ unzip -p YOUR.ods meta.xml | xml sel --template --value-of office:document-meta/office:meta/dc:date | tr -d ':TZ-' | perl -pe 's/^(.*)..*$/$1/'


Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.