March 28, 2016

Downloading a free Oreilly book

O'reilly sometimes offers free books, which is a fantastic service. If you ever wondered how to read the entire book off line.

All you have to do is download it. But if the book is divided into chapters in seperate files, how do you get just the book files? The answer lies in a single simple oneliner with wget.

# wget -r --no-parent -A pdf http://www.oreilly.com/openbook/make3/book/

This downloads the book in the current directory, under the directories www.oreilly.com/openbook/make3/book/. Now you have your book present in a single directory. If you wish, you can now join all the seperate pdf files into a single book. For this you need a program called pdftk (pdf toolkit) if you don't have it installed already

# sudo port install pdftk # will install it on OSX using mac ports, or
# sudo aptitude install pdftk # will install it on debian based Linux

With pdftk in place, check the order of the various book parts on the books oreilly page, and then construct a command line following that structure.

# cd www.oreilly.com/openbook/make3/book
# pdftk cpyrt.pdf toc.pdf author_colo.pdf part1.pdf ch01.pdf ch02.pdf ch03.pdf \ ch04.pdf ch05.pdf part2.pdf ch06.pdf ch07.pdf ch08.pdf ch09.pdf ch10.pdf ch11.pdf \ ch12.pdf part3.pdf appa.pdf appb.pdf appc.pdf inx.pdf cat output \ ManagingProjectsWithGnuMake.pdf

Voila, you have a brand new book.

No comments: