Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 5 years ago.
I am writing a script that will move files from a local system to a remote system. It must do so through an encrypted channel like ssh. What is the best way to do this? I can perform this in two steps like:
scp *.jpg user@ip:
rm *.jpg
But, that is not an atomic process (like mv is for a local filesystem). If the copy fails I will no longer have the local copies either. How can I script this to make sure the local files only get removed if the copy succeeds?