I have to cleanup an archive directory on a remote host only if there are files to be archived; the source files are on the same host. I should run something similar to:

cd $source_dir
if [ -f *.tar.gz ]
  rm -fr $arch_dir/*
  mv *.tar.gz $arch_dir

The problem is that I can use only scp, rsync or sftp. How to achieve this?


given those requirements, why not use something like python/perl on the client side for an interactive sftp session, then you can easily check for the file existence in the archive directory and move the files, etc.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.