Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

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

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

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

4 Answers 4

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.

share|improve this answer

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.

share|improve this answer

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
share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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