Todays sysadmin tip: Download files from a web directory

Just a small hot tip today. I have this bunch of rpms that are available at a directoroy exported by http somwhere. How do I download all of them in one go? Or even: How do I download one of them, given I only remember the base name, not the version? , Compulsory: No clicking involved?

wget -r -nd -l 1 -A *rpm http://some.where.tld/path/to/rpms

That’s so useful, I’d make it a bash alias

alias myget="wget -r -nd -l 1 -A"

myget perl-Date-Calc* http://mirror.ii.uib.no/centos/5/os/SRPMS
ls
perl-Date-Calc-5.4-1.2.2.1.src.rpm

3 Responses to “Todays sysadmin tip: Download files from a web directory”

  1. Kjetil T. says:

    very nice! I changed it into a function so I could get at the argument(s):

    myget() {
    local url
    for url; do wget -r -nd -l 1 -A “${url##*/}” “${url%/*}”; done
    }

    now usage becomes: myget URL [URL ...], e.g.,

    myget http://mirror.ii.uib.no/centos/5/os/SRPMS/perl-Date-Calc*

  2. Jesse Keating says:

    See also lftp and the mirror command, or mget *. lftp is rather hot as it handles globs.

  3. [...] Todays sysadmin tip: Download files from a web directory « On the … [...]

Leave a Reply