Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
-n, --no-clobber
do not overwrite an existing file (overrides a previous -i
option)
-P, --no-dereference
never follow symbolic links in SOURCE
-p same as --preserve=mode,ownership,timestamps
--preserve[=ATTR_LIST]
preserve the specified attributes (default: mode,ownership,time-
stamps), if possible additional attributes: context, links,
xattr, all
--no-preserve=ATTR_LIST
don't preserve the specified attributes
Can you look and see how old this man page is? Or does anyone know off hand, how long the -n option has been around? My "cp" has been around since 2008 and i get "invalid option -- n" when I try to use it and it's not in the man page.
The -n option has been introduced in coreutils version 7.1 at the beginning of year 2009. Here is the ChangeLog notification:
Code:
2009-01-14 Kamil Dudka <kdudka@redhat.com>
cp/mv: add --no-clobber (-n) option to not overwrite target
* src/cp.c (usage): Show new option -n in --help.
(main): Handle new option -n.
* src/mv.c (usage): Show new option -n in --help.
(main): Handle new option -n.
Sorry to necropost, but this was pretty high up in Google search results (#1 for "cp no clobber"), so I thought I'd offer a solution for Googlers.
For some weird reason, the -n option wasn't working for me either (which is of course how I got here; I Googled it, lol), but typing:
Code:
# echo 'n' | cp -i
is essentially equivalent to the --no-clobber option, and worked perfectly for me.
I hope this helps!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.