Operating System - HP-UX
1748201 Members
2992 Online
108759 Solutions
New Discussion

Re: critical files comparison on to different path & copying

 
Dennis Handly
Acclaimed Contributor

Re: critical files comparison on to different path & copying

>I want to copy the missing files from first path to second path...i.e file b, d & f ...

 

rsync will do that.

But if you have empty files or files with different content in the second path, then rsync will make them the same.  So if you don't want that or don't want to wasted time copying them files, you need somthing else.

 

>here is a script that will compare 2 directories ...

 

You can simplify the logic in the while loop with comm(1):

 

# Use comm(1) to output all the files in TMP1 that are not in TMP2, both must be sorted

comm -23 ${TMP1} ${TMP2} | while read FILE; do
   echo "Copying ${DIR1}/${FILE} to ${DIR2}"
   cp -p ${DIR1}/${FILE} ${DIR2}
done

Patrick Wallek
Honored Contributor

Re: critical files comparison on to different path & copying

Are these scripts what you wanted? 

Vishal_1980
Regular Advisor

Re: critical files comparison on to different path & copying

Hello Experts,

 

Thanks all for your help....

Much appriciated....

 

With best regards,

Vishal