A piece of software software I need to install on my Ubuntu Hardy system has a Makefile which includes the command cp -n.

However, I get an error stating that -n is an invalid option.

The command will work on a Mac terminal but I need it to work on Ubuntu.

Does anyone know the equivalent command for Ubuntu?

link|improve this question
1  
Step up a level from the immediate question -- look harder for linux (or debian or ubuntu) installation instructions. Unless this is a very niche or internal tool, there are likely installation instructions which will work better on Ubuntu. – Doug Harris May 13 '10 at 13:50
feedback

migrated from stackoverflow.com May 13 '10 at 13:20

This question came from our site for professional and enthusiast programmers.

4 Answers

In FreeBSD (it's like Mac OS X in many ways) the option -n means "Do not overwrite an existing file." I think that in ubuntu you can use the -u flag that means update that copy only if destination is older than the source or if destination is missing.

link|improve this answer
feedback

The -n flag means "no clobbering" (do not replace existing files when copying). You can use cp -i to have cp ask whether a file should be overwritten.

link|improve this answer
feedback

Note that if you're using cp in an automated build script, the bash rewrite would simply be:

cp -n src dest

to

if [ ! -e dest ]; then
    cp -f src dest
fi
link|improve this answer
feedback

cp in GNU coreutils 7.6 certainly has the -n option. Use cp --version to verify the version of cp that is being used.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.