Используйте подходящий инструмент. Curl и wget делают все, что вам нужно, они написаны для надежной работы и включены в каждый дистрибутив.
-A acclist
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. In this case, you have to enclose the pattern into quotes to prevent your shell from expanding it, like in -A ".mp3" or -A '*.mp3'.
Итак, вам нужно изменить bmp,avi
по шаблону. Примерно так:
wget --tries=3 --retry-on-http-error=429,503,504 -r -l 1 -A 123adf*bmp,123adf*avi -nd -H --user-agent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092416 Firefox/3.0.3" https://www.site.com