2017-02-16 196 views
0

我在FTP服务器上有一个“备份”目录。我想用CURL删除这个目录下的所有文件。可能吗?我试过:用CURL删除FTP目录内容

curl --ssl ftp://aaa:[email protected] -Q "RMD backup" 

但似乎它只适用于空目录。

附注:我不知道这个目录中的文件的确切列表。

回答

0

curl一起使用一些shell脚本,你应该能够做到这一点。例如:

#!/bin/bash 

# Get the list of files in the directory. Note that the 
# trailing slash is important! 
for f in `curl --ssl ftp://aaa:[email protected] backup/`; do 

    # Delete each file individually 
    curl --ssl ftp://aaa:[email protected] -Q "DELE backup/$f" 
done 

# You can remove the now-empty directory 
curl --ssl ftp://aaa:[email protected] -Q "RMD backup" 

希望这有助于!