LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cp command (https://www.linuxquestions.org/questions/linux-newbie-8/cp-command-843293/)

pgte3 11-09-2010 02:19 PM

cp command
 
I am trying to use the cp command on a Unix system, reading the man pages for both Linux and Unix, the syntax and usage seem very close.

Running the command on the Unix system:

cp -R /test/tomcat/apache-tomcat-5.5.20/webapps/passweb10 /test/tomcat/apache-tomcat-5.5.20/webapps/passweb10bkup

Where both /test/tomcat/apache-tomcat-5.5.20/webapps/passweb10 and /test/tomcat/apache-tomcat-5.5.20/webapps/passweb10bkup exist, I get the following error.

cp: FSUM6829 building pathname "/test/tomcat/apache-tomcat-5.5.20/webapps/passweb10bkup/passweb10/": EDC5129I No such file or direct
ory.

Any ideas what I am doing wrong?

cparapat 11-09-2010 02:38 PM

Maybe you wrong path
 
Quote:

Originally Posted by pgte3 (Post 4153972)
I am trying to use the cp command on a Unix system, reading the man pages for both Linux and Unix, the syntax and usage seem very close.

Running the command on the Unix system:

cp -R /test/tomcat/apache-tomcat-5.5.20/webapps/passweb10 /test/tomcat/apache-tomcat-5.5.20/webapps/passweb10bkup

Where both /test/tomcat/apache-tomcat-5.5.20/webapps/passweb10 and /test/tomcat/apache-tomcat-5.5.20/webapps/passweb10bkup exist, I get the following error.

cp: FSUM6829 building pathname "/test/tomcat/apache-tomcat-5.5.20/webapps/passweb10bkup/passweb10/": EDC5129I No such file or direct
ory.

Any ideas what I am doing wrong?

How if you try, go with "cd /test/tomcat/apache-tomcat-5.5.20/webapps/" first. And do a list directory with "ls" command. See if there is the folder you mean is there ? Just want to make sure.

pgte3 11-09-2010 02:45 PM

Yes, both passweb10 and passweb10bkup directories exist in /test/tomcat/apache-tomcat-5.5.20/webapps.

niiiro 11-09-2010 03:28 PM

you could try using rsync command instead.. it goes like this:

rsync avrRp <source dir> <destination dir>

if rsync command wasn't found - install the rsync package.

GazL 11-09-2010 04:15 PM

You need the "-T" option on the cp command, otherwise the copy will try and copy the source into the existing destination. i.e. you'll get a ./passweb10bkup/passweb10/ rather than a ./passweb10bkup/

theNbomr 11-09-2010 08:14 PM

This might do it.
Code:

cp -R /test/tomcat/apache-tomcat-5.5.20/webapps/passweb10/* /test/tomcat/apache-tomcat-5.5.20/webapps/passweb10bkup
--- rod.

cparapat 11-10-2010 01:17 AM

Need Sudo
 
I think you need "sudo" command. Be "sudo cp -R ..". My opinion your directory destination is not have your permission to copy or updating the files. Is it true ?

pgte3 11-10-2010 08:27 AM

Thanks for your suggestions. Upon further investigation and reading the documentation, there seems to be a difference in the -r and -R option (see below).

-R (UNIX to UNIX only) "Clones" the source trees. cp copies all the files and subdirectories specified by source... into directory, making careful arrangements to duplicate special files (FIFO, character special). cp only follows symbolic link specified as source operand on the command line.

-r (UNIX to UNIX only) "Clones" the source trees, but makes no allowances for special files (FIFO, character special). Consequently, cp attempts to read from a device rather than duplicate the special file. This is similar to, but less useful than, the preferred -R.



Not exactly sure, what "special" files are, but this command seems to work:

cp -r /test/tomcat/apache-tomcat-5.5.20/webapps/passweb10 /test/tomcat/apache-tomcat-5.5.20/webapps/passweb10bkup

chrism01 11-11-2010 12:27 AM

Re special files: http://tldp.org/LDP/abs/html/fto.html
Loosely speaking, nearly everything in *nix is treated as a 'file', but only a few things like regular files & dirs are really 'just files'. See that page.


All times are GMT -5. The time now is 04:07 PM.