# Wget regex fails getting files over ftp

From the site

ftp://atmos.nmsu.edu/PDS/data/mslrem_1001/DATA/

I want to download the files ending in .TAB and have in the name RMD for all the suns. For that I have tried the following command:

wget -r -nd --accept-regex '.*(RMD)\d+\_+[A-Z][0-9]\.(TAB)' ftp://atmos.nmsu.edu/PDS/data/mslrem_1001/DATA/SOL_00001_00089/SOL00010/


The url is different just to try it. The problem is that wget ignores the regex expression and downloads all the files but I don't know why.

Try something simpler:

wget -r -nd -A '*RMD*.TAB' ftp://atmos.nmsu.edu/PDS/data/mslrem_1001/DATA/

• Is there a solution which supports the regex? The glob here would match lots of files not matched by the regex above. – Quantum7 Apr 25 '18 at 9:44

You could try globbing instead of Regex. From the manual:

‘--no-glob’

Turn off FTP globbing. Globbing refers to the use of shell-like special characters (wildcards), like ‘*’, ‘?’, ‘[’ and ‘]’ to retrieve more than one file from the same directory at once, like:

wget ftp://gnjilux.srk.fer.hr/*.msg


By default, globbing will be turned on if the URL contains a globbing character. This option may be used to turn globbing on or off permanently.

You may have to quote the URL to protect it from being expanded by your shell. Globbing makes Wget look for a directory listing, which is system-specific. This is why it currently works only with Unix FTP servers (and the ones emulating Unix ls output).

Example:

wget -r -nd "ftp://atmos.nmsu.edu/PDS/data/mslrem_1001/DATA/*.TAB"