2
How can I get all files downloaded from a FTP site directory with file name like emp*.
Please suggest.
2
How can I get all files downloaded from a FTP site directory with file name like emp*.
Please suggest.
2
I tested this bash
one liner against a CentOS 6.5 FTP mirror successfully, but I have anonymized it to prevent abuse:
for i in `curl -i ftp://ftp.example.com/pub/centos/6.5/updates/i386/repodata/ | awk '{print $9}' | grep ^8`; do curl -O http://ftp.eample.com/pub/centos/6.5/${i} ; done
To explain, this goes to the ftp server, gets the directory listing (first curl), pipes the data into awk to only return the filenames. Finally, this is piped into grep to only match on those files starting with the number 8 to simulate your emp*
requirement.
Those filtered filenames become the variable i
and I then use a simple for loop to fetch each one by appending them to the URL for the second curl request. I ended up with these two files:
-rw-r--r-- 1 adam staff 362 11 Jul 13:22 819455e9f840760fcbdccf0283e4324ceabc8512f246e911d39424760ed1729e-primary.xml.gz
-rw-r--r-- 1 adam staff 360 11 Jul 13:22 8e4d3dd261375d31b35b6870e187d841633c68a400e4d11bb7234fea517cdbaa-other.xml.gz
0
If I'm not missing something all you need to do is cd in to the directory and use "mget emp*". You may want to change the "prompt" setting (it's a toggle command) if you don't want to respond to every file Y/N.
1Welcome to SuperUser! What have you tried? It is expected of you to try something first and to include that in your original post, with any references you used. – l0b0 – 2014-07-11T10:48:35.983