The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM



Thread: list of files
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 08-10-2007
blowtorch's Avatar
blowtorch blowtorch is offline
Supporter
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,332
You can use rsync for this. Rsync works over ssh as well. If you have to write your own script, you can do something like this:

1. ssh to remote and get list of files (use ssh and ls on remote path)
2. compare remote list with local list and create list of files to remove (files that are not present locally) (use comm command)
3. ssh to remote and remove files that are in the list (use ssh and rm on remote path)
4. scp files from local to remote (scp as in current script)
Reply With Quote