?
Solved

In aix unix how to copy files/dirs without overwritting the old files

Posted on 2012-08-29
7
Medium Priority
?
1,975 Views
Last Modified: 2012-09-11
I have 100 files/dirs in server A and 10 of those are in Server B. How can i copy over those 100 files/dirs without overwriting the 10 that already exist in Server B?

In essence need to copy just the 90 files/dirs of the 100 from server A to server B.
0
Comment
Question by:assistunix
7 Comments
 
LVL 21

Expert Comment

by:netcmh
ID: 38347080
use the -n switch to cp
0
 
LVL 21

Assisted Solution

by:netcmh
netcmh earned 400 total points
ID: 38347092
AIX should have it, if not try

cp –help

-n, –no-clobber do not overwrite an existing file (overrides a previous -i option)


Alternatively,  you can use rsync

rsync -r –ignore-existing bar/. foo/.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 38347097
cp -i ... ...

will ask before overwriting, giving the opportunity to say "No".

If this is not an option "rsync" could be the tool of choice. It's available at http://www.perzl.org/aix
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 21

Expert Comment

by:netcmh
ID: 38347102
Just remembered something simple.

You could use the yes command

yes n | cp -R -h -i /dir1/* /dir2
0
 
LVL 48

Accepted Solution

by:
Tintin earned 1200 total points
ID: 38348082
The requirement is to copy files over the network, so cp won't work unless it's a NFS mounted directory or similar.

rsync is the best tool to use, eg:

rsync -av -ignore-existing /some/dir user@serverB:/dest/dir

Open in new window

0
 

Author Comment

by:assistunix
ID: 38366826
Thank you all for your responses- I tried using rsync, however syntax seems to be wrong for it, as it gives an error. Could you assist.

# rsync -av -ignore-existing /home/bin root@test:/home/bin

rsync: Failed to exec -existing: No such file or directory (2)
rsync error: error in IPC code (code 14) at pipe.c(84) [sender=3.0.6]
rsync: writefd_unbuffered failed to write 4 bytes to socket [sender]: Broken pipe (32)
rsync error: error in IPC code (code 14) at io.c(1525) [sender=3.0.6]
0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 400 total points
ID: 38366901
It's
"--ignore-existing"

with two dashes!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question