Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use regular expressions in wget for rejecting files?

I am trying to download the contents of a website using wget tool. I used -R option to reject some file types. but there are some other files which I don't want to download. These files are named as follows, and don't have any extensions.

string-ID

for example:

newsbrief-02

How I can tell wget not to download these files (the files which their names start with specified string)?

like image 277
Hakim Avatar asked Jun 27 '12 17:06

Hakim


1 Answers

Since (apparently) v1.14 wget accepts regular expressions : --reject-regex and --accept-regex (with --regex-type posix by default, can be set to pcre if compiled with libpcre support).

Beware that it seems you can use --reject-regex only once per wget call. That is, you have to use | in a single regex if you want to select on several regex :

wget --reject-regex 'expr1|expr2|…' http://example.com
like image 127
Skippy le Grand Gourou Avatar answered Sep 22 '22 17:09

Skippy le Grand Gourou