Operating System - HP-UX
1820695 Members
2731 Online
109627 Solutions
New Discussion юеВ

mv command with recursive option for movig directory trees

 
SOLVED
Go to solution
Shivkumar
Super Advisor

mv command with recursive option for movig directory trees

looks like recursive move command
"$mv -r olddir newdir" doesn't work.
only "$cp -R sourcedir destinationdir" with recursive option works..right ??
just wanted to move directory and its subdirectory along with files to new locations.

Regards,
Shiv
7 REPLIES 7
Vibhor Kumar Agarwal
Esteemed Contributor

Re: mv command with recursive option for movig directory trees

Simple mv will do your job.

mv olddir newdir

Will move your whole olddir to newdir.
Vibhor Kumar Agarwal
Devender Khatana
Honored Contributor

Re: mv command with recursive option for movig directory trees

Hi,

-r is not required to be specified for moving directories using mv command. mv takes both filename and directory names as options.

$mv dir1 dir2

$mv filename dir2

Refer man page for further details.

HTH,
Devender
Impossible itself mentions "I m possible"
Vibhor Kumar Agarwal
Esteemed Contributor
Solution

Re: mv command with recursive option for movig directory trees

Just to add a thing.

mv is a recursive command.

It changes the inode table, so no need to use the -r option.
All other sub-directories refer via inode only.
Vibhor Kumar Agarwal
Arunvijai_4
Honored Contributor

Re: mv command with recursive option for movig directory trees

Hi Shiv,

"-r" is not required to move recursively. Just simple "mv old new" will do the job for you.

You can take a look at # man mv for more information and examples.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Arunvijai_4
Honored Contributor

Re: mv command with recursive option for movig directory trees

Hi Shiv,

This doc should be helpful to you.

http://www.centos.org/docs/2/rhl-gsg-en-7.2/s1-managing-working-with-files.html

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Arturo Galbiati
Esteemed Contributor

Re: mv command with recursive option for movig directory trees

Hi Shiv,
simply mv olddir newdir
It moves olddir and all its subdirs to newdir.
HTH,
Art
Cem Tugrul
Esteemed Contributor

Re: mv command with recursive option for movig directory trees

Hi Shiv,

http://docs.hp.com/en/B2355-90164/ch02s05.html
http://docs.hp.com/en/B2355-90164/ch02s13.html
Our greatest duty in this life is to help others. And please, if you can't