I putty across to two different Ubuntu servers (A and B). I would like to SFTP from A to B and get
all the files in a directory in B to A and delete the files in B straight after the download - so that only A has the files.
How can achieve get
files and delete the file straight after a successful transfer/download?
You can use the following to remove remote files:
and for remote directories:
Where you replace
[path]
with your actual path or file name or directory name. This as well can be wildcards as you are used to in normal terminal. for recursively getting directories you might need the-r
flag.Sadly there is no command for moving the files from B to A so you need to get the files from B to A and then remove the files on B. means there is no command to concatenate the get and the remove together.
For getting and then deleting the files in bulk you can use wildcards.
Example (let's assume you have your files inside a folder XY on your server B):