Skip download if files exist in wget?

后端 未结 4 1851
[愿得一人]
[愿得一人] 2021-01-29 18:39

This is simplest example running wget:

wget http://www.example.com/images/misc/pic.png

but how to make wget skip download if pic.png

相关标签:
4条回答
  • 2021-01-29 19:13

    The -nc, --no-clobber option isn't the best solution as newer files will not be downloaded. One should use -N instead which will download and overwrite the file only if the server has a newer version, so the correct answer is:

    wget -N http://www.example.com/images/misc/pic.png
    

    Then running Wget with -N, with or without -r or -p, the decision as to whether or not to download a newer copy of a file depends on the local and remote timestamp and size of the file. -nc may not be specified at the same time as -N.

    -N, --timestamping: Turn on time-stamping.

    0 讨论(0)
  • 2021-01-29 19:21

    When running Wget with -r or -p, but without -N, -nd, or -nc, re-downloading a file will result in the new copy simply overwriting the old.

    So adding -nc will prevent this behavior, instead causing the original version to be preserved and any newer copies on the server to be ignored.

    See more info at GNU.

    0 讨论(0)
  • 2021-01-29 19:29

    The answer I was looking for is at https://unix.stackexchange.com/a/9557/114862.

    Using the -c flag when the local file is of greater or equal size to the server version will avoid re-downloading.

    0 讨论(0)
  • 2021-01-29 19:30

    Try the following parameter:

    -nc, --no-clobber: skip downloads that would download to existing files.

    Sample usage:

    wget -nc http://example.com/pic.png
    
    0 讨论(0)
提交回复
热议问题