下面的脚本将删除远程目录中的所有.tar.gz文件。
要影响删除哪些文件,请更改grep值。
请注意,此脚本已经过测试,并适用于我们的情况,但您的特定设置可能需要额外的测试和调试。
#!/bin/sh
ftp_path=/remote/ftp/path
ftp_username=username
ftp_password=password
ftp_ip=remote.host.com
ftp_port=21
for i in `curl -s -l ftp://"$ftp_username":"$ftp_password"@$ftp_ip/$ftp_path/ | grep tar.gz`; do
{
echo "deleting ${ftp_path}/$i";
curl ftp://${ftp_ip}:${ftp_port}/${ftp_path}/${i} -u "${ftp_username}:${ftp_password}" -O --quote "DELE ${ftp_path}/${i}"
};
done;











