1832525 Members
7500 Online
110043 Solutions
New Discussion

equivalent of cp

 
SOLVED
Go to solution
Hunki
Super Advisor

equivalent of cp


what can be the equivalent "cp -rp" for the mv command.

there is a directory which i created using cp -rp ..here is the exmaple :

cp -rp prot prot.0510.

Now I want to move the prot.0510 to prot using the mv command rather than the cp or a combination of cp and rm.

9 REPLIES 9
Patrick Wallek
Honored Contributor

Re: equivalent of cp

Your kidding, right?

# mv prot.0510 prot.0511

Did you try looking at the mv man page?
Hunki
Super Advisor

Re: equivalent of cp

mv prot.0510 prot
mv: prot.0510 is a directory

mv -f prot.0510 prot
mv: prot.0510 is a directory

Sandman!
Honored Contributor

Re: equivalent of cp

What OS system are you on? The mv command works without errors on my HP-UX box.
Sandman!
Honored Contributor

Re: equivalent of cp

Hit the submit button prematurely. Below is the excerpt from my hpux box.

# ls -ldrt prot.0510 prot
drwxr-xr-x 3 root sys 96 May 10 15:52 prot
drwxr-xr-x 2 root sys 96 May 10 15:54 prot.0510

# mv prot.0510 prot

# ls -ldrt prot.0510 prot
prot.0510 not found
drwxr-xr-x 3 root sys 96 May 10 15:54 prot
Patrick Wallek
Honored Contributor
Solution

Re: equivalent of cp

According to your previous post, the prot directory already exists.

If you want to mv the CONTENTS of the prot.0510 directory to the prot directory, then try:

# cd prot.0510
# mv * ../prot

or

# mv prot.0510/* prot

The man pages are rather helpful if you read them.
Hunki
Super Advisor

Re: equivalent of cp

# cd prot.0510
# mv * ../prot

it works but the prot directory is not removed altogether , which I want.
Hunki
Super Advisor

Re: equivalent of cp

Also Sandman it works the first time around but if the directory already exist then it gives those errors.
Sandman!
Honored Contributor

Re: equivalent of cp

Try forcing mv into moving the files and then removing the directory viz.,

# mv -e force prot.0510 prot

~cheers
Dennis Handly
Acclaimed Contributor

Re: equivalent of cp

>Sandman
# ls -ldrt prot.0510 prot
drwxr-xr-x 3 96 May 10 15:52 prot
drwxr-xr-x 2 96 May 10 15:54 prot.0510
# mv prot.0510 prot
# ls -ldrt prot.0510 prot
prot.0510 not found

This is elementary container theory. When you move prot.0510 to prot, you put it inside prot.
(I assume that was Sandman's point?)