Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving directories and sub directories

Status
Not open for further replies.

trisco

MIS
Jan 3, 2001
44
US
I'm a little confused regarding the mv command. I wish to move a directory, its sub-directories and files within one file system to another file system without the source directory becoming a subdirectory of the target directory. Example:
Source: /fs1/sub1/*
Target: /fs2/*
Suspected command syntax: mv /fs1/* /fs2/*
/fs2 directory is existing, but empty.
Would this accomplish the move correctly?
I'm running AIX at 4.3.3 ML8.

Any help to understanding the move is appreciated?
 
Unfortunately, if my memory serves me correctly, the mv command does not move directories from one file system to another. Also, mv will not work if both directories do not have\share the same parent directory.

You could possibly look at using the tar or the cpio command to accomplish your directory move. Do a man on mv or the others for clearer info.

Best wishes
Chris
 
A few options...?

If you have it all contained in a logical volume...check this out...using cplv


You can also back it up and restore it...

or use the migratepv -l command within the same same volume group

If between a different volume group
Usually you back up and remove old...then restore...instead of tape you
can do
smit crfs (make sure that /tempfs1 in vg00 is same size as original fs1)
mount /tempfs1
cd /fs1
find . -print | backup -iqf /tempfs1/file.back
cd
unmount /fs1
rmfs /fs1
smit crfs (/fs1 in vg00 the same size as /tempfs1)
mount /fs1
cd /fs1
restore -xqf /tempfs1/file.back
unmount /tempfs1
rmfs /tempfs1

Or if it is large...back it up, relative (change to that directory) then restore in new filesystem.
 
Thanks for your input. The source files are not in a unique LV nor are the source and target files in the same VG or LV.

If the backup and restore method (which may be closer to what I want) is used, wouldn't the restore lay the backed up files down in the same directory path names? I want the resultant file directory names to be something other that the original.
 


You could also copy them and then remove from the original if you had the space...it is also safer that way?

To copy a directory, including all its files and subdirectories, to another directory, enter:

cp -R /home/nick/clients /home/nick/customers

This copies the clients directory, including all its files, subdirectories, and
the files in those subdirectories, to the customers/clients directory.
 
Thanks for the reply. I do have the space reserved, so the cp command is the way that I will proceed.
Trisco
 
I agree with aixqueen that "cp" is the safest method to do the move. However, you can use the "mv" command to move a directory and it's content across filesystems, both jfs and nfs. Change to the parent directory of the directory to be moved, then use the mv command as in my example below:

cd fs1
mv sub1 /fs2

Actually, you can skip the cd, and just do:

mv /fs1/sub1 /fs2

You don't need to use the wildcards.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top