Using wget to recursively fetch a directory with arbitrary files in it

前端 未结 14 2066
再見小時候
再見小時候 2020-11-27 08:31

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 directo

14条回答
  •  暖寄归人
    2020-11-27 09:12

    The following option seems to be the perfect combination when dealing with recursive download:

    wget -nd -np -P /dest/dir --recursive http://url/dir1/dir2

    Relevant snippets from man pages for convenience:

       -nd
       --no-directories
           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 (if a name shows up more than once, the
           filenames will get extensions .n).
    
    
       -np
       --no-parent
           Do not ever ascend to the parent directory when retrieving recursively.  This is a useful option, since it guarantees that only the files below a certain hierarchy will be downloaded.
    

提交回复
热议问题