1833738 Members
2629 Online
110063 Solutions
New Discussion

Re: mv question

 
SOLVED
Go to solution
chapaya_1
Frequent Advisor

mv question

Hi ,

I have this directory /appl/appl ,
I want to move the whole directory to /appl .

What is the best way ?

BYE
14 REPLIES 14
Michael Tully
Honored Contributor
Solution

Re: mv question

cd /appl/appl
mv * ..

rm -f appl1
Anyone for a Mutiny ?
Mark Grant
Honored Contributor

Re: mv question


mv /appl/* /appl
rmdir /appl/appl
Never preceed any demonstration with anything more predictive than "watch this"
Franky_1
Respected Contributor

Re: mv question

Hi,

just type

cd /appl/appl
tar cfv - .|(cd ../; tar xfv -)
cd ..
rm -r appl

That's it

Franky
Don't worry be happy
Frederic Sevestre
Honored Contributor

Re: mv question

Hi,

You can try

cd /appl
tar cf - appl | (cd / ; tar xvf -)
rmdir /appl/appl

Regards,
Frederic
Crime doesn't pay...does that mean that my job is a crime ?
YoungHwan, Ko
Valued Contributor

Re: mv question

# cd /appl/appl

# find . -dept -print | cpio -pudmv /appl

# cd /appl

# rm -r /appl/appl

MarkSyder
Honored Contributor

Re: mv question

Could I just add to Michael and Mark's excellent answers that you may have files that start with . (dot) so you should also do:

cd /appl/appl
mv .* ..

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
chapaya_1
Frequent Advisor

Re: mv question


I got this :

hp1:>pwd
/appl/appl
hp1:>mv * ..
hp1:>ls
.cshrc .exrc .login .profile
hp1:>mv .* ..
mv: ../.: rename: Device busy
mv: .. and .. are identical
hp1:>ll
total 0

The files moved but i got this error ...
Francisco J. Soler
Honored Contributor

Re: mv question

Hi,

another way to do it:

cd /
mv /appl/appl /temp_dir
rm -rf /appl
mv /temp_dir /appl

Frank.
Linux?. Yes, of course.
V. Nyga
Honored Contributor

Re: mv question

Hi,

this happened, because you also tried to moved '.' and '..' in the upper directory.(where this files already exists.)
You can ignore this error message.
But maybe '..' isn't there any more?
Check it with 'll -a'

Then type 'cd /apps' to move one step up.

Volkmar
*** Say 'Thanks' with Kudos ***
Mark Grant
Honored Contributor

Re: mv question

Actually, mine answer had a bug in it :(

The worry of moving ".*" is that it'll take the current directory and the parent directory too.

Really it should be something like

mv /appl/appl/.[!.]* /appl
mv /appl/appl/* /appl
rmdir /appl/appl
Never preceed any demonstration with anything more predictive than "watch this"
MarkSyder
Honored Contributor

Re: mv question

Sory, I'd overlooked the fact that it would try to move . and .. : I have mv aliased so it asks for confirmation on each file. Always a good idea (unless there are a very large number of files in the directory).

Mark
The triumph of evil requires only that good men do nothing
Franky_1
Respected Contributor

Re: mv question

Hi,

so my solution works and even copies the .dot files.
Wouldn't it be fair to assign points for that?

Franky
Don't worry be happy
chapaya_1
Frequent Advisor

Re: mv question

HI ,

You are right Franky ....


BYE
Francisco J. Soler
Honored Contributor

Re: mv question

Hi,

I think it is not necessary to perform a tar command, my solution is easier than Franky's solution, only moving directories is enough. Nevertheless Franky's solution is good.

Frank.
Linux?. Yes, of course.