I have a host that I can only access with sftp, scp, and rsync-- no ssh. I have a large tree of directories that I want to delete, but my sftp client apparently does not support recursive rms or rmdirs. In the help screen, it shows I can do recursive puts, but that doesn't help me.

How can I delete my files?


You can use the lftp client to do this. The the -r option to lftp rm recursively deletes directories and files.

$ lftp -u <user>,<pass> <server> 
lftp> rm -r <directory>



rsync has several delete options -

--delete            delete extraneous files from dest dirs
--delete-before     receiver deletes before xfer, not during
--delete-during     receiver deletes during the transfer
--delete-delay      find deletions during, delete after
--delete-after      receiver deletes after transfer, not during
--delete-excluded   also delete excluded files from dest dirs

any of these should remove files on your host once deleted from your local copy.

  • rsync doesn't support sftp. Also, a concrete example might help to explain how to use these options better. – starbeamrainbowlabs Mar 12 at 21:18
  • 1
    @starbeamrainbowlabs The question states I can only access with sftp, scp, and rsync - it isn't asking about only sftp. – sambler Mar 23 at 3:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.