this post was submitted on 12 Feb 2025
14 points (100.0% liked)

Linux

3189 readers
12 users here now

founded 3 years ago
MODERATORS
 

I was trying to do that but I noticed ls | grep searchterm just searches the book TITLES for searchterm. Is this possible, to search the text of ebooks?

you are viewing a single comment's thread
view the rest of the comments
[โ€“] Coelacanthus 1 points 1 day ago (1 children)

For example, something like epub is going to be hard because the format is really just a zip file with a specific internal file structure. So, it's not really the .epub file you want to grep, but one of the files within that zip file you want to grep through.

ePub is a zip file contains a batch of HTML file for contents and some XML files for metadata. So you can extract it and do grep as you do for HTML files.

That was just the first example to pop to mind where you couldn't just grep search * and I didn't want to get into a bunch of specific file formats. For something like epub you could probably just use zcat and then pipe the output to grep. Perhaps using a for loop if you want to do other fancy stuff along the way (e.g. output file names as headers).

So ya, "hard" may have been a bit overblown. "not simple" may have been better. But, without the OP actually stating what format the ebooks were in, I wasn't going to write a primer on dealing with any format.