Reputation: 31948
I have a directory "backup" on an FTP server. I want to delete all files in this directory using CURL. Is it possible? I tried:
curl --ssl ftp://aaa:bbb@ccc -Q "RMD backup"
But seems it only works on empty directory.
Side note: I don't know the exact list of files in this directory.
Upvotes: 2
Views: 7223
Reputation: 31948
I created a crontab that runs everyday and delete the backup that is 10 days old. So since it runs everyday, there is no "old" backups:
curl --ssl ftp://aaa:bbb@ccc -Q "DELE sql/$(date -d '+10 days' +'%Y-%m-%d').sql"
Upvotes: 1
Reputation: 3089
Using some shell script in conjunction with curl
, you should be able to do this. For example:
#!/bin/bash
# Get the list of files in the directory. Note that the
# trailing slash is important!
for f in `curl --ssl ftp://aaa:bbb@ccc backup/`; do
# Delete each file individually
curl --ssl ftp://aaa:bbb@ccc -Q "DELE backup/$f"
done
# You can remove the now-empty directory
curl --ssl ftp://aaa:bbb@ccc -Q "RMD backup"
Hope this helps!
Upvotes: 4