Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Not really a question this one - but alternative answers are certainly welcome! :)

Sometimes I need to download files listed in an Apache directory listing, say as in:

... in a given directory on my computer, and I'd like to use command-line tools for that.

As far as wget is concerned, actually there are some switches that should be in place - noting that wget tends to either download single items - or to reconstruct the server folders locally!

As I just spent some half an hour figuring out what those proper switches are (to copy the remote files locally as through, say, FTP), I'd like to document them here; so the above link would be downloaded with:

wget -nd -r -l 1 http://www.gnu-darwin.org/www001/src/ports/net/samba-libsmbclient/work/samba-3.0.28/source/libsmb/

... where:

       Do not create a hierarchy of directories when retrieving
       recursively.  With this option turned on, all files will get saved
       to the current directory, without clobbering [...]

       Turn on recursive retrieving.

   -l depth
       Specify recursion maximum depth level depth.  The default maximum
       depth is 5.

It would be nice to hear alternatives to the above command - maybe using different set of switches for wget - or maybe using curl or other packages...

share|improve this question

1 Answer 1

See also -nH a.k.a --no-host-directories and --cut-dirs options. I also frequently use --accept/-A and --reject/-R.

share|improve this answer
Many thanks for these options, @jw013 - great to have a quick reference for them! Cheers! –  sdaau Sep 19 '11 at 19:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.