Shell script for comparing and moving files from remote server
Posted on 2009-02-17
I need a script, which can do the following.
1. it will copy a file named A (file A contains filenames like 1.txt.gz, 2.txt.gz and so on in separate lines) to a directory /test
2. It will search for a file named B in /test directory
3. If no file B exists, it will read all the lines of file A without .gz (for example if file names are 1.txt.gz then the input will be like 1.txt) (as I previously mentioned file A contains 1 filename in each lines) and transfer those files from remote server by ssh or ftp (scp is preferable).
4. After transferring it will rename the file A to file B in /test directory.
5. upon next execution if file B exists in the /test directory, then also it will copy file A but now we need to compare it with file B. If some uniq entries are found between file A and file B, it will copy those files from remote server(solaris 10) and rename file A to file B. if file A is same as file B the script simply exit.
6. All activity needs to be logged.
Please help me.
Thanks and regards,