Example output of ebook-meta unixpowertools.epub:
Title : UNIX Power Tools, 3rd Edition
Author(s) : Jerry Peek, Shelley Powers, Tim O’Reilly & Mike Loukides [Jerry Peek, Shelley Powers, Tim O’Reilly, and Mike Loukides]
Publisher : O’Reilly Media
Tags : COMPUTERS / Operating Systems / UNIX
Languages : eng
Published : 2009-02-08T23:00:00+00:00
Rights : Copyright © 2009 O’Reilly Media, Inc.
Identifiers : isbn:9780596103699
Comments : <p>The latest edition of this best-selling favorite is loaded with vital information on Linux, Darwin, and BSD. <i>Unix Power Tools</i> 3rd Edition now offers more coverage of bash, zsh, and other new shells, along with discussions about modern utilities and applications. Several sections focus on security and Internet access. There is a new chapter on access to Unix from Windows, and expanded coverage of software installation and packaging, as well as basic information on Perl and Python.</p>
We can use awk to get the title only:
ebook-meta unixpowertools.epub | awk -F "^Title +: " 'NF > 1 {print $2}'
For the example file above, this produces:
UNIX Power Tools, 3rd Edition
Some ebooks contain the "Title sort" field, which this command doesn't extract but might be relevant to you.
Explanation of the command
awk -F "^Title +: sets awk's separator to "Title" (which has to be at the start of a line due to the ^ anchor), followed by at least one whitespace followed by a colon and space.
NF > 1 will skip empty lines, where no separator was found
{print $2} prints the second colon which is the text after the string matched by ^Title +:
Here are more ways to get the string after a prefix, using regular expressions.
Supported ebook formats
Regarding the supported file formats, I quote from the manual:
Supported formats for reading metadata: azw, azw1, azw3, azw4, cbr, cbz, chm, docx, epub, fb2, fbz, html, htmlz, imp, lit, lrf, lrx, mobi, odt, oebzip, opf, pdb, pdf, pml, pmlz, pobi, prc, rar, rb, rtf, snb, tpz, txt, txtz, updb, zip
Supported formats for writing metadata: azw, azw1, azw3, azw4, docx, epub, fb2, fbz, htmlz, lrf, mobi, odt, pdb, pdf, prc, rtf, tpz, txtz