Skip to content

Instantly share code, notes, and snippets.

@eggplants
Last active August 18, 2021 07:28
Show Gist options
  • Save eggplants/3e843b7681581efb908a2cbb22595550 to your computer and use it in GitHub Desktop.
Save eggplants/3e843b7681581efb908a2cbb22595550 to your computer and use it in GitHub Desktop.
#!/bin/bash -ex
command -v gs > /dev/null || {
echo "gs(ghostscript) is not found">&2
exit 1
}
command -v curl > /dev/null || {
echo "curl is not found">&2
exit 1
}
BASE=https://www.oreilly.co.jp/library/4873112699/
TMPDIR="$(mktemp -d)"
curl -s "$BASE" | sed -nE 's;^.*"([^/"]+pdf)".*$;\1;p' |
sed "s;^;${BASE};g" | while read -r i
do
curl "$i" -o "$TMPDIR/$((cnt++)).pdf"
done
ls -tr "$TMPDIR" | sed "s;^;${TMPDIR}/;g" |
xargs gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=gnu-make-book.pdf
rm -rf "$TMPDIR"
SCRIPT=make-make-book.sh
all: $(SCRIPT)
bash $(SCRIPT)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment