Linux: Follow and Download using wget

Your Linux box is incomplete if you do not have wget installed. It is a simple CLI based application used to download files from network.  It support HTTP, HTTPS and FTP protocols as well as retrieval through HTTP proxies.

 

 

Download latest version of PHPmyAdmin from SourceForge.

 

You can just simply use the latest link of SourceForge software and wget will automatically follow it. You also need to specify the ‘content-disposition’ flag. This option is useful for some file-downloading CGI programs that use “Content-Disposition” header to describe what the name of a downloaded file should be:

$ wget --content-disposition http://sourceforge.net/projects/phpmyadmin/files/latest/download

Download TokuMX  with cookies and redirection from Tokutek download site.

 

To download from this page, I was required to have cookies from download.php=tokumx-1.0-3-linux-x86_64.tgz page and use the same cookies to download from download.php?df=1. You can navigate to this page if you want to try that with a web browser, http://www.tokutek.com/download.php?download_file=tokumx-1.0.3-linux-x86_64.tgz.

$ wget --keep-session-cookies \
--save-cookies cookies.txt \
http://www.tokutek.com/download.php?download_file=tokumx-1.0.3-linux-x86_64.tgz && \
wget --load-cookies cookies.txt \
--content-disposition http://www.tokutek.com/download.php?df=1 && \
rm -f download.php* cookies.txt

 

Download Certain Files from Web Directory

 

You can download certain files (*.gz) under same directory using wget with -r flag. You need to specify –no-directories and –no-host-directories to output the files in the current directory while –level is the depth of the directory it will go:

$ wget -r --accept="*.gz" \
--no-directories \
--no-host-directories \
--level 1 \
ftp://ftp.fu-berlin.de/pub/misc/movies/database/

 

I will keep updating this page to share my collection of wget commands.