tags:

views:

6862

answers:

3

I have a web directory where I store some config files. I'd like to use wget to pull those files down and maintain their current structure. For instance, the remote directory looks like:

http://mysite.com/configs/.vim/

.vim holds multiple files and directories. I want to replicate that on the client using wget. Can't seem to find the right combo of wget flags to get this done. Any ideas?

+1  A: 
wget -r http://mysite.com/configs/.vim/

works for me.

Perhaps you have a .wgetrc which is interfering with it?

Conor McDermottroe
A: 

You should be able to do it simply by adding a -r

wget -r http://stackoverflow.com/
kasperjj
+11  A: 

For me I have to pass the --no-parent option, otherwise it will follow the link in the directory index on my site to the parent directory. So the command would look like this:

wget -r --no-parent http://mysite.com/configs/.vim/

Edit: To avoid downloading the index.html files, use this command:

wget -r --no-parent --reject "index.html*" http://mysite.com/configs/.vim/
yjerem
this is close but for me it downloads a bunch of non-existent files that look like index.html?C=M;O=A index.html?C=N;O=A etc, etc.
sant0sk1
Ah, that's because your server's directory indexing page has links to sort the directory listing, which wget is following. You should add this to your question.
yjerem
I've edited my answer with what I think should solve that problem.
yjerem
shouldn't it reject index.htm files too? ;)
Spoike
booyah! Thanks!!
sant0sk1
Thanks! Is it possible to prevent it from creating the whole directory structure instead of starting from the root? i.e. make it only create the .vim folder and not everything before it.
verhogen