For some reason, an open course at MIT decided to post only the chapters of their textbook without also posting the entire textbook itself.

No problem, a few shell commands and BAM! full textbook pdf…

*NOTE: this only works if the urls for the pdfs are indexed by numbers.

In this case, the url pattern for the pdfs are ..._chap<NUMBER>.pdf, where <NUMBER> is 01, 02, …,19.

1 - Download

First, we download all the pdfs as chapter_<NUMBER>.pdf:

curl -o chapter_#1.pdf '[01-20].pdf'

2 - Merge

Next, we merge using pdfunite:

pdfunite chapter_* mit_6.02.pdf

3 - Clean up

And, delete the originals:

rm chapter_*