Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recursive remove directory using SFTP

I use SFTP server for making database backup and all web site with it structure. I use bad script and now I make double duplicates on my SFTP server. I use rmdir folder but I get error:

Couldn't remove directory: Failure

If I understand right in SFTP I can remove directory just if it empty. And if I use rm folder/* I don't remove inner folders.

How I can doit another way?

like image 412
itdxer Avatar asked Dec 10 '13 22:12

itdxer


People also ask

How do I delete a directory in SFTP?

To remove any directory from your remote SFTP session, run the following rmdir command followed by the directory you want to (in this example, directoryA will be removed).

How do I delete a directory recursively?

To remove a directory and all its contents, including any subdirectories and files, use the rm command with the recursive option, -r . Directories that are removed with the rmdir command cannot be recovered, nor can directories and their contents removed with the rm -r command.


1 Answers

You can also mount your remote directory with

sshfs [email protected]:/path/to/remote local/path

then just cd local/path and then you are free to use rm -r folder

like image 74
user43284 Avatar answered Sep 20 '22 15:09

user43284