- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- critical Files comparison on to different path & c...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2014 11:48 AM
09-03-2014 11:48 AM
critical Files comparison on to different path & copying
Hello expert,
We have below path on the UNIX box ,
/home/accpd/tobleer/ssp8install/lsoct/patches & /lya/c1s2d6/ranson/var/install/PORTAL/patches
There are few files on the first path & second path as well. I need to compair all the files.
My porblem is i need to compair the files on both the path & need to copy files which are not mention under the second path from the first path .There are more than 30 to 80 fileson both the path , below are the output....
/home/accpd/tobleer/ssp8install/lsoct/patches $ ls -l
total 305066
-rwxrwxrwx 1 tobleer accpd 502787 Aug 18 17:31 lsoct_AIX61_09000111P18646.zip
-rwxrwxrwx 1 tobleer accpd 502598 Aug 18 17:31 lsoct_AIX61_09000111P19282.zip
-rwxrwxrwx 1 tobleer accpd 496631 Aug 18 17:31 lsoct_AIX61_09000111P19682.zip
-rwxrwxrwx 1 tobleer accpd 575693 Aug 18 17:31 lsoct_AIX61_09000111P20477.zip
-rwxrwxrwx 1 tobleer accpd 500371 Aug 18 17:31 lsoct_AIX61_09000111P20959.zip
-rwxrwxrwx 1 tobleer accpd 494793 Aug 18 17:31 lsoct_AIX61_09000111P22491.zip
-rwxrwxrwx 1 tobleer accpd 786346 Aug 18 17:31 lsoct_AIX61_09000111P22748.zip
-rwxrwxrwx 1 tobleer accpd 4261294 Aug 18 17:31 lsoct_AIX61_09000111P23912.zip
-rwxrwxrwx 1 tobleer accpd 496464 Aug 18 17:31 lsoct_AIX61_09000111P23993.zip
-rwxrwxrwx 1 tobleer accpd 17797402 Aug 18 17:31 lsoct_AIX61_09000111P26740.zip
-rwxrwxrwx 1 tobleer accpd 496425 Aug 18 17:31 lsoct_AIX61_09000111P28066.zip
-rwxrwxrwx 1 tobleer accpd 131104868 Aug 18 17:31 lsoct_AIX61_09000111P28645.zip
&
lya/c1s2d6/ranson/var/install/PORTAL/patches $ ls -l
total 4352
-rw-rw-rw- 1 root ranson 548336 Feb 14 2013 XML_09000111P19534.jar
-rw-r----- 1 root system 506313 Jan 15 2013 XML_09000111P19534.zip
-rw-rw-rw- 1 root ranson 605262 Feb 14 2013 XML_09000111P19654.jar
-rw-r----- 1 root system 563534 Jan 15 2013 XML_09000111P19654.zip
Always i need to compair the files both the location & need to copy those files which are not present in the below
lya/c1s2d6/ranson/var/install/PORTAL/patches
Can i do this using the script comparing the files from both the location & copying the file from the first location to the second location which are not present in the second location ..
Thanks & regards,
Vishal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2014 12:18 PM
09-03-2014 12:18 PM
Re: critical Files comparison on to different path & copying
The tool 'rsync' is built precisely for this type of task.
rsync will check the files in each directory and determine what needs to be done to make the destination directory the same as the source.
In its most basic form, this will sync the source and the destination directories:
# rsync -av /home/accpd/tobleer/ssp8install/lsoct/patches/ /lya/c1s2d6/ranson/var/install/PORTAL/patches/
There are numerous options to rsync that will allow you to do numerous things, one of which is to remove files from the destination directory if the are removed from the source directory.
- Tags:
- rsync
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2014 12:46 PM
09-03-2014 12:46 PM
Re: critical Files comparison on to different path & copying
However we have to do this for HP-UX & AIX as well.
For HP-UX it will work , can you please suggest for AIX as well.
As its a need for the production.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2014 12:52 PM - edited 09-03-2014 12:53 PM
09-03-2014 12:52 PM - edited 09-03-2014 12:53 PM
Re: critical Files comparison on to different path & copying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2014 12:53 PM
09-03-2014 12:53 PM
Re: critical Files comparison on to different path & copying
And there are more than 80 files on each of the path.I just need that the files from the first & second path will be tallied out & the file which are missing in the second path will be copied from the first path.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2014 03:23 PM - edited 09-03-2014 03:34 PM
09-03-2014 03:23 PM - edited 09-03-2014 03:34 PM
Re: critical files comparison on to different path & copying
>I need to compare all the files.
Compare the just names or also the content?
>can you provide me such script so that the whole process
Doesn't Patrick's one line work for you?
rsync -av /home/accpd/tobleer/ssp8install/lsoct/patches/ /lya/c1s2d6/ranson/var/install/PORTAL/patches/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2014 03:26 PM
09-03-2014 03:26 PM
Re: critical Files comparison on to different path & copying
Just the name not the content ...
Thanks
Vishal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2014 03:34 PM
09-03-2014 03:34 PM
Re: critical files comparison on to different path & copying
>Just the name not the content
I think rsync's job is to copy the data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2014 03:51 PM
09-03-2014 03:51 PM
Re: critical files comparison on to different path & copying
Let me put in a simple way ....
Suppose on the first path there are files namely : a , b , c , d , e , f & g & on the second path there are files namely a,c ,e,& g ...Now here i want to tally the files ( & i am talking about 80 files aprox) now i want to copy the missing files from first path to second path...i.e file b , d & f ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2014 11:42 AM
09-04-2014 11:42 AM
Re: critical files comparison on to different path & copying
Since you seem to not want to use rsync (though I don't understnad why...), here is a script that will compare 2 directories and copy whatever the files that exist in DIR1 but not in DIR2 from DIR1 to DIR2.
# cat test.sh
#!/usr/bin/sh
DIR1=/tmp/test1
DIR2=/tmp/test2
TMP1=/tmp/dir1.$$
TMP2=/tmp/dir2.$$
/usr/bin/ls -1A ${DIR1} > ${TMP1}
/usr/bin/ls -1A ${DIR2} > ${TMP2}
while read FILE
do
grep -q ^${FILE}$ ${TMP2}
EXIST=$?
if (( ${EXIST} != 0 )) ; then
echo "Copying ${DIR1}/${FILE} to ${DIR2}"
cp -p ${DIR1}/${FILE} ${DIR2}
fi
done < ${TMP1}
rm ${TMP1} ${TMP2}
Modify the DIR1 and DIR2 directory variables to suit your needs.
Here is what my DIR1 and DIR2 looked like BEFORE I ran the script:
# ll /tmp/test1 /tmp/test2
/tmp/test1:
total 16
drwxr-xr-x 2 root sys 96 Sep 4 13:57 .
drwxrwxrwt 10 root root 8192 Sep 4 14:32 ..
-rw-r--r-- 1 root sys 0 Sep 4 13:57 file1
-rw-r--r-- 1 root sys 0 Sep 4 13:57 file3
-rw-r--r-- 1 root sys 0 Sep 4 13:57 file5
-rw-r--r-- 1 root sys 0 Sep 4 13:57 file7
/tmp/test2:
total 16
drwxr-xr-x 2 root sys 96 Sep 4 13:57 .
drwxrwxrwt 10 root root 8192 Sep 4 14:32 ..
-rw-r--r-- 1 root sys 0 Sep 4 13:57 file1
-rw-r--r-- 1 root sys 0 Sep 4 13:57 file7
Here is what they looked like after I ran the script:
# ll /tmp/test1 /tmp/test2
/tmp/test1:
total 16
drwxr-xr-x 2 root sys 96 Sep 4 13:57 .
drwxrwxrwt 10 root root 8192 Sep 4 14:35 ..
-rw-r--r-- 1 root sys 0 Sep 4 13:57 file1
-rw-r--r-- 1 root sys 0 Sep 4 13:57 file3
-rw-r--r-- 1 root sys 0 Sep 4 13:57 file5
-rw-r--r-- 1 root sys 0 Sep 4 13:57 file7
/tmp/test2:
total 16
drwxr-xr-x 2 root sys 96 Sep 4 14:35 .
drwxrwxrwt 10 root root 8192 Sep 4 14:35 ..
-rw-r--r-- 1 root sys 0 Sep 4 13:57 file1
-rw-r--r-- 1 root sys 0 Sep 4 13:57 file3
-rw-r--r-- 1 root sys 0 Sep 4 13:57 file5
-rw-r--r-- 1 root sys 0 Sep 4 13:57 file7
The first time you run the script I would comment out the 'cp' command so it will just echo the information so you can verify that the script is working correctly.
Hopefully this satisfies your needs.