LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 06-15-2011, 05:17 AM   #1
rabiticide
Member
 
Registered: Dec 2008
Posts: 42

Rep: Reputation: 15
noclobber for "cp" command?


I *think* I have used this command before:

cp -np source destination

n - noclobber
p - preserve timestamps, etc

I must be remembering wrong because I can't find this "noclobber" option to the "cp" command. What am I thinking of?


rK
 
Old 06-15-2011, 05:35 AM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
wget has a noclobber option.
 
Old 06-15-2011, 05:44 AM   #3
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
From 'man cp':

Code:
       -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
 
Old 06-15-2011, 03:38 PM   #4
rabiticide
Member
 
Registered: Dec 2008
Posts: 42

Original Poster
Rep: Reputation: 15
H TexMex H:

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.
 
Old 06-15-2011, 03:45 PM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by rabiticide View Post
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.
How do you know what year it's from? Is your distro past its end of life, or did you not update using your package manager?

To find out what version you have, run "cp --version".
 
Old 06-15-2011, 03:46 PM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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.
 
1 members found this post helpful.
Old 06-16-2011, 05:06 AM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Code:
bash-4.1$ cp --version
cp (GNU coreutils) 8.11
Copyright (C) 2011 Free Software Foundation, Inc.
 
Old 05-28-2013, 11:27 PM   #8
Sweyn78
Member
 
Registered: Jul 2011
Location: Watkinsville, GA
Distribution: Arch Linux
Posts: 43

Rep: Reputation: 4
Lightbulb Solution

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!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Errors executing shell script: "command not found" and "no such file or directory" eko000 Linux - Newbie 1 01-14-2011 07:54 AM
ns:"error when calling class OldSim"&tclsh:"invalid command+child process exits abn." shojaru Linux - Newbie 0 03-05-2009 04:23 AM
Feeding the output of "diff" or "cat" command to dpkg --purge kushalkoolwal Debian 9 06-19-2008 07:27 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
Tiny Sofa 2.0 - I thought "halt", "reboot" were only root command ?? sorcerer Linux - Distributions 1 08-21-2004 03:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration