I like to periodically append some data to a remote file via ssh
and remove it locally. Like:
cat some_lines_to_append.txt | ssh [email protected] 'cat >> all_lines_collected.txt'
rm some_lines_to_append.txt
Now I like to make sure some_lines_to_append.txt
is only removed, if the lines where successfully transfered. How to do that?
Does >>
create some sort of error return code by itself on failure, or does cat
in this case, and will ssh
deliver that return code?
Will shh
itself deliver non-zero return codes in any occasion that it was finished prematurely?