I am using the following to download a file using wget only if it has changed since its last download.
wget --directory-prefix="$DIR" --content-disposition --timestamping "$URL"
I want wget to name the file as appropriate (the URL is passed into my script so I do not know what it might be) and I want to use --timestamping, so I cannot use --output-document.
How can I determine the file name used?
I thought I could search in $DIR for the most recent file, but that wouldn't work if there are multiple files in that directory (there could be) and the file is already the latest one determined using timestamping.
If the processing of Content-Disposition
isn't important (since I'm not sure curl does it) then you can use curl
for this instead.
outfile=$DIR/foo
curl -z "$outfile" -o "$outfile" --remote-time "$URL"
But be careful not to use a filename that curl
might parse as a date (the -z
flag is stupid that way).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.