A Linux bash script to download all pdf files from a page

Are you trying to download multiple files from a webpage and bored from clicking and clicking ??

I needed to download like a 100 PDF from a single web page , so I started to look for a bash script that automates the process and found this interesting article by Guillermo Garron that combines several useful programs into a nice script to download all links from a page using lynx command line web browser and wget downloader.

First , install the the browser

$ sudo apt-get install lynx

Lynx has a nice feature that allows you to grab all links from a page

$ lynx --dump http://mlg.eng.cam.ac.uk/pub/ >> ~/links.txt

The output will be like this 

Image

So we need to filter out the first numbering column and all non pdf links for the output to be nice and readable by wget

$ lynx --dump //http://mlg.eng.cam.ac.uk/pub/  | awk '/http/{print $2}' | grep pdf  >> ~/links.txt

Resulting in a clean input to wget 

Image

and the last step is to pass this file into wget to download all the pdfs

$ for i in $( cat ~/links.txt ); do wget $i; done

 voilà ! you get all the files downloaded 

Image

How to install Ubuntu 12.04 over Fedora 17 keeping Windows 7 dual boot

I have spent a few days playing around with different boot scenarios to remove Fedora and install Ubuntu but keeping dual boot with Windows 7 intact and here is the juice of my experience 🙂

* If you are booting from USB live disk make sure to disable UEFI from BIOS options and run in legacy mode (sometimes referred as CSM)

Method 1

1 – Use Disk Management from Windows  (Run -> diskmgmt.msc), find the Fedora partitions, delete them and format but this will delete GRUB and you will not be able to boot hence you need to restore MBR.

2 – To restore the MBR using Ubuntu live CD you should simply install lilo

sudo apt-get install lilo

sudo lilo -M /dev/sda mbr

3 – Then you can install Ubuntu normally alongside with windows using the installer which will be able to automatically detect  Windows 7 installation.

This should be the perfect scenario but actually this is not what really happened to me during my trials,

What happened to me is that I damaged the MBR by accident so I got the error

BOOTMGR is missing.

after rebooting the machine.

Method 2

So I plugged in the ubuntu live usb disk -> install and when asked where to install I chose something else then I chose the 2 Fedora partitions as the installation partitions and checked the option to format them

/dev/sda1 -> /boot

/dev/sda2 -> /

Ubuntu installation automatically fixed MBR and installed GRUB and now I can happily dual boot Ubuntu 12.04 and Windows 7 🙂

So I guess this is a second and an easier  method to install Ubuntu >= 12.04 over fedora just by using the live disk and choosing fedora partitions as Ubuntu installation partitions.