Home > Bash, Tip, wget > A few wget tips

A few wget tips

In *nix world, wget is a very handy tool to download files from remote ftp or http servers. This post will present a few wget tips that I use quite often in my (mostly Bash) scripts:

1) use –quiet option to surpress download progress indicator
wget --quiet http://host_name_of_the_server/path/to/afile.doc

2) use -N to get file only when timestamp or size of the file downloaded has changed
wget -N http://host_name_of_the_server/path/to/somefile.dat
If file somefile.dat has been downloaded and file size and/or timestamp has not changed on the remote server, downloading of the file somefile.dat will be skipped to save bandwidth (and disk io).

3) when running wget under bash, one can take advantage of Bash curl braces expansion and do something like this
wget http://host_name_of_the_server/path/to/{file1.txt,file2.txt,file3.txt}
or
wget http://host_name_of_the_server/path/to/{file1,file2,file3}.txt
or even
wget http://host_name_of_the_server/path/to/file{1,2,3}.txt

Each of the above commands is equivalent to the following
wget http://host_name_of_the_server/path/to/file1.txt
wget http://host_name_of_the_server/path/to/file2.txt
wget http://host_name_of_the_server/path/to/file3.txt

With less code you get more done.

Advertisements
Categories: Bash, Tip, wget
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: