Tag Archives: ebook

epub.sh: Me and Anders and Esko

Some months ago Anders left a note here about a simple script to spill a .epub file into your terminal, without needing another application to read it. Anders credited Esko for the original version, and while it might be presumptuous, I have adjusted Anders’ version slightly too.

Here’s my contribution to the effort, which still needs a little attention at times.

if [[ -z "$1" ]]
    then echo "Usage: ./epub.sh book.epub"
if [[ -z "$2" ]]
    then COLS=`tput cols`
FILELIST=`zipinfo -1 "$1" | grep -E '\.xml|\.html|\.xhtml' |sort`
    TEXT="$TEXT `unzip -caa "$1" "$FILE" | html2text -width $COLS`"
echo "$TEXT" | $PAGER

Which on my screen generates:


My additions to the script are to

  • Rely on your $PAGER in the final line,
  • Add in support for xhtml files, because the epub I downloaded to test it used xhtml 🙄 , and
  • Allow you to pick the width of your terminal, or leave it blank to use the full available width.

Of course, like Anders mentioned, this relies on both unzip and html2text, although the latter could be substituted with another tool, if you prefer it.

And it needs a lot of work. The ultimate effect is the “wall of text,” which I personally despise. As you might notice from my short paragraphs on this blog. 😐

And some better formatting would be nice, as well as some trapping for the leftover HTML that seems to have crept into the display at the top and elsewhere.

But not bad overall. I still count a neverending “Hello World” on my C64 as my greatest programming achievement, but this will do for my contribution. You have my permission to add yours. 😉

fbless: The things I learn

Until I started poking around with fbless, I hadn’t ever heard of fictionbook format. Wikipedia tells me it originated in Russia and is still popular there; that’s the first I knew of it, and still pretty much is all I know.


fbless is nothing terribly complex. Best I can tell, it parses the format and spins the text out through a less-like viewer. Many of the same commands are available, so you can page through a document, jump back to the top or see how the story ends, or search the text for strings.

That’s about it. I know this is a very superficial once-over, but fbless itself carries no documentation, accepts no help flags, and the home page is in Russian. 😐

I can send it through Google Translate, but that doesn’t tell me a lot that I didn’t already know. I suppose something like this should be accepted for what it does, not what it doesn’t do.

So I can’t really say anything bad about fbless. I don’t feel like I was sold short; in fact I learned one or two new things. I should get that much out of every little program I install. 😉