Linux – curl –ftp-ssl to grab all files in remote directory

curllinux

Is it possible to get all files in a directory using curl? Here's my string so far:

curl --ftp-ssl -k ftp://user:pass@IP

This will LIST the files in the user FTP directory, how do I adjust this string to get (RETR) all files in the remote directory?

Best Answer

AFAIK, there is no such option to download a directory with curl, so you must get the listing first and pipe it to curl to download file by file, something like this:

$ curl -s ftp://user:pass@IP/path/to/folder/ | \
    grep -e '^-' | awk '{ print $9 }' | \
        while read f; do \
            curl -O ftp://user:pass@IP/path/to/folder/$f; \
        done