2017-02-16 198 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" 

希望這有助於!