Wget with wildcards in http downloads

wget

I need to download a file using wget, however I don't know exactly what the file name will be.

https://foo/bar.1234.tar.gz

According to the man page, wget lets you turn off and on globbing when dealing with a ftp site, however I have a http url.

How can I use a wildcard while using a wget? I'm using gnu wget.

Things I've tried.

/usr/local/bin/wget -r "https://foo/bar.*.tar.gz" -P /tmp

Update

Using the -A causes all files ending in .tar.gz on the server to be downloaded.

/usr/local/bin/wget -r "https://foo/" -P /tmp -A "bar.*.tar.gz"

Update

From the answers, this is the syntax which eventually worked.

/usr/local/bin/wget -r -l1 -np "https://foo" -P /tmp -A "bar*.tar.gz"

Best Answer

I think these switches will do what you want with wget:

   -A acclist --accept acclist
   -R rejlist --reject rejlist
       Specify comma-separated lists of file name suffixes or patterns to 
       accept or reject. Note that if any of the wildcard characters, *, ?,
       [ or ], appear in an element of acclist or rejlist, it will be 
       treated as a pattern, rather than a suffix.

   --accept-regex urlregex
   --reject-regex urlregex
       Specify a regular expression to accept or reject the complete URL.

Example

$ wget -r --no-parent -A 'bar.*.tar.gz' http://url/dir/
Related Question