You can make this process successful in 2 steps: -
1] rsync -e ssh -z foo.txt remotemachine:/home/me/somedirectory/
this will copy the foo.txt file and create the somedirectory
directory at the destination.
then
2] rsync -e ssh -z --delete-after foo.txt remotemachine:/home/me/somedirectory/bar.txt
and here you can delete foo.txt by destination using the --delete-after
option. you can see its use from man pages. This option should be used with the -r option. This serves your purpose.
or if the second command does not work, use: - rsync -e ssh -z foo.txt remotemachine:/home/me/somedirectory/bar.txt
and manually delete the file foo.txt.
source share