ric*_*ich 8 linux terminal command-line curl checksum
有没有办法获得一个程序,我可以通过命令行运行,该程序将执行远程文件的校验和?例如,获取https://stackoverflow.com/opensearch.xml的校验和
我希望能够获得有关新rss/xml条目何时可用的更新.我以为我可以偶尔对文件进行校验和,如果它不同则必须有更新.我正在寻找一个shell脚本来检查新的rss/xml数据.
小智 5
curl 有一个“-z”选项:
-z/--time-cond <date expression>|<file>
(HTTP/FTP) Request a file that has been modified later
than the given time and date, or one that has been modified before
that time. The <date expression> can be all sorts of date strings
or if it doesn't match any internal ones, it is taken as a filename
and tries to get the modification date (mtime) from <file> instead.
See the curl_getdate(3) man pages for date expression details.
Run Code Online (Sandbox Code Playgroud)
所以你可以做的是:
$ curl http://stackoverflow.com/opensearch.xml -z opensearch.xml -o opensearch.xml
Run Code Online (Sandbox Code Playgroud)
如果远程文件比本地文件年轻,这将进行实际下载(本地文件可能不存在 - 在这种情况下将被下载)。这似乎正是你所需要的......
wget 也有跟踪时间戳的选项 - -N
When 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.
-N, --timestamping Turn on time-stamping.
Run Code Online (Sandbox Code Playgroud)
因此,万一 wget 可以使用:
$ wget -N http://stackoverflow.com/opensearch.xml
Run Code Online (Sandbox Code Playgroud)
小智 5
使用curl执行此操作的快速方法是将输出通过管道输出到sha1sum,如下所示:
curl -s http://stackoverflow.com/opensearch.xml|sha1sum
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
13267 次 |
最近记录: |