I am trying to recursively download the contents of a particular directory (via http from a web server) using wget. The command I am using is:

wget -r -l 0 --user=josh --ask-password http://morris.cs.example.com/files/Software/MySoftware/V2012_Linux

wget then appears to download the contents of the parent directories rather than just the intended child directory (V2012_Linux).

How do I modify my command to download only the contents of the child directory and also place it in a directory of my choosing?

1 Answer 1


I think you're looking for

-np, --no-parent                 don't ascend to the parent directory.


wget -r -l 0 -np --user=josh --ask-password http://morris.cs.example.com/files/Software/MySoftware/V2012_Linux/

Wget doesn't give much flexibility with output file names. If you want recursive downloading, you have to let the structure of the downloaded tree match the structure as served. Move V2012_Linux where you want it once the download is finished, or create a symbolic link.

  • Thanks Gilles, your answer was helpful, however in my particular case, I needed to ensure that the trailing slash / was present. From wget's manual: "Note that, for HTTP (and HTTPS), the trailing slash is very important to ‘--no-parent’. HTTP has no concept of a “directory”—Wget relies on you to indicate what's a directory and what isn't. In ‘foo/bar’, Wget will consider ‘bar’ to be a directory, while in ‘foo/bar’ (no trailing slash), ‘bar’ will be considered a filename (so ‘--no-parent’ would be meaningless, as its parent is ‘/’)."
    – Josh
    Feb 13, 2013 at 0:00
  • @Josh Right, thank you, I'd forgotten about that. Feb 13, 2013 at 0:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .