- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: cp command options
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
Forums
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
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
10-20-2005 05:13 AM
10-20-2005 05:13 AM
What is the option to use while using cp command so that any existing files with the same names are not overwritten ?
Thanks,
Shiv
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2005 05:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2005 05:20 AM
10-20-2005 05:20 AM
Re: cp command options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2005 05:20 AM
10-20-2005 05:20 AM
Re: cp command options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2005 05:22 AM
10-20-2005 05:22 AM
Re: cp command options
# man cp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2005 05:23 AM
10-20-2005 05:23 AM
Re: cp command options
I don't know any option with the cp command that would do what you want.
Regards
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2005 05:26 AM
10-20-2005 05:26 AM
Re: cp command options
cp -i will do the work. As man page says,
-i (interactive copy) Cause cp to write a prompt to standard error and wait for a response before copying a file that would overwrite an existing file. If the response from the standard input is affirmative, the file is copied if permissions allow the copy. If the -i (interactive) and -f (forced-copy)options are both specified, the -i option is ignored.
Regards,
Syam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2005 05:34 AM
10-20-2005 05:34 AM
Re: cp command options
cp itself does not have a protection like you seek.
Protect the files that previously exist. Example: cp the originals off somewhere, do your copy. then cp the originals back.
If you do the cp as root, changing the perms will not protect the originals.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2005 05:36 AM
10-20-2005 05:36 AM
Re: cp command options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2005 05:49 AM
10-20-2005 05:49 AM
Re: cp command options
sorry, i am not an expert in unix sys admin world and hence lots of silly questions.
Thanks,
Shiv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2005 05:54 AM
10-20-2005 05:54 AM
Re: cp command options
Lets go through an example.
Move (copying) /usr
Copy a directory from one location to another. Even if it has "special" files and links in it:
cd /usr
find . -print | cpio -dlmpuvx /usr2
d = Do directories
l = Do links
m = Keep time
p = Pass along
u = Copy unconditionaly
v = verbose
x = Save device special files
for copying data from one disk to another disk.
find . -depth -print | cpio -odmv > newdisk
see complete command ref.
http://docs.hp.com/en/B2355-60105/cpio.1.html
Regards,
Syam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2005 05:57 AM
10-20-2005 05:57 AM
Re: cp command options
===============
Copy the contents of a directory into a tape archive:
ls | cpio -o > /dev/rmt/c0t0d0BEST
Duplicate a directory hierarchy:
cd olddir
find . -depth -print | cpio -pd newdir
The trivial case
find . -depth -print | cpio -oB >/dev/rmt/c0t0d0BEST
can be handled more efficiently by:
find . -cpio /dev/rmt/c0t0d0BEST
Regards,
Syam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2005 06:05 AM
10-20-2005 06:05 AM
Re: cp command options
cp='/usr/bin/cp -i'
Also, a good idea for rm and mv commands:
rm='/usr/bin/rm -i'
mv='/usr/bin/mv -i'
Also, again in .profile, you can prevent shell output redirection from overwriting existing files.
for posix and korn shells:
set -o noclobber
see the man pages for additional explanation.
- John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2005 08:36 PM
10-20-2005 08:36 PM
Re: cp command options
the best should be to define an alias:
alias cp='cp -i'.
It this way any time you try to cp a file if teh detsination file is not empty teh command asks for your confirmation.
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2005 08:48 PM
10-20-2005 08:48 PM
Re: cp command options
set noclobber
This prevents files from being overwritten.
Mark Syder (like the drink but spelt different)