1
epubcat book.epub 1 3
# outputs plain text of pages 1 through 3

I don’t know if epubs have the concept of “pages.” If not, perhaps we can say each 400 chars are a page? A general solution that works for other ebook formats is better (mobi, azw3, etc).

My own thoughts are currently on first converting the book to text via ebook-convert or pandoc and then extracting the needed amount, but this seems awfully inefficient as I intend to only get a little of the beginning of the content.

You can download an example file that can be used for testing here.

terdon
  • 234,489
  • 66
  • 447
  • 667
HappyFace
  • 1,493
  • 9
  • 21
  • You can read `.epub` books with this [.jar tool](https://github.com/bayang/termepub). However, I didn't find any way how to use it in shell script. – BlueManCZ Apr 10 '20 at 09:48
  • Can you link us to a file we can use for testing? – terdon Apr 10 '20 at 09:59
  • @terdon here: http://82.102.11.148:8080//tmp/Time%20to%20Put%20Your%20Galleons%20Where%20Your%20Mouth%20Is%20-%20Tsume%20Yuki.epub – HappyFace Apr 10 '20 at 10:42

1 Answers1

1

You can use mutool:

mutool draw -F text file.epub 1 2>/dev/null

The redirection 2>/dev/null is optional.

lezambranof
  • 321
  • 3
  • 5