I'm trying to learn script and found this post Extract TOC from epub file, which give me part of solution that I need, but when I tested it, got an error error: Extra content at the end of the document.
A little bit of background: I have 2 epub files: 1.epub and 2.epub. I tested each one separately, it worked fine (got the TOC from each epub), but when I tried to test both files using do, got the above error.
I'm learning scripts, not sure if I made a mistake somewhere. Anyone can point what's my mistake?
ps: my script
#! /usr/bin/bash
EPUB_LIST="1.epub 2.epub"
for f in "$EPUB_LIST"
do
echo "$f:"
unzip -p "$f" OEBPS/toc.ncx |
xml2 |
sed -n -e 's:^/ncx/navMap/navPoint/navLabel/text=: :p'
echo
done