Move directory


 
Thread Tools Search this Thread
Operating Systems AIX Move directory
# 1  
Old 11-23-2012
Move directory

Hi All,

please help me with the command for moving/copying one directory(including subdirectories) to one directory in another mount point in same server in AIX ...


thanksss
# 2  
Old 11-23-2012
Recursive Copying by preserving ownership & permissions:-
Code:
cp -pr source_dir destination_dir

Or you can use tar for copying:-
Code:
tar cfp source_dir.tar source_dir
cd destination_dir
tar xvfp source_dir.tar

# 3  
Old 11-24-2012
Quote:
Originally Posted by bipinajith
Or you can use tar for copying:-
Code:
tar cfp source_dir.tar source_dir
cd destination_dir
tar xvfp source_dir.tar

I don't think your tar commands will work unless you move the f option to the end of the group so that it's immediately followed by the archive filename.

You could also just pipe from one tar into another, avoiding the storage overhead of creating a third copy of the hierarchy. However, with regard to archivers, using pax would be simpler than tar:
Code:
pax -rw src dest

Regards,
Alister

Last edited by alister; 11-24-2012 at 08:32 AM..
# 4  
Old 11-24-2012
use backup file format

Generally I just type a command at the command line doing:
Code:
$ cd old; find . | backup -if - | (cd /some/where/new; restore -xqf -)


Last edited by Scott; 11-24-2012 at 08:12 AM.. Reason: Added code tags; removed link
# 5  
Old 11-24-2012
Moving and copying aren't the same thing. If you want to move the directory you simply need to use the mv command.
# 6  
Old 11-24-2012
Quite right, mv is not cp - but the question was for moving/copying. And when I am moving across filesystems I prefer to copy, and remove later. Saves a lot of hassle when it turns out there is not enough space to receive the "copy". Under the covers, when crossing filesystems mv does a copy followed by remove.

btw: I do not recommend using tar as transport, and would need to verify commands like cpio. Reason? Tar is not quaranteed to retain sparse file information whereas backup|restore will.
# 7  
Old 11-28-2012
Thanks All for your support and HelpSmilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

2. Shell Programming and Scripting

How Create new directory and move files to that directory.?

Hi All, We have main directory called "head" under this we have several sub directories and under these directories we have sub directories. My requirement is I have to find the SQL files which are having the string "procedure" under "head" directory and sub directories as well. And create... (14 Replies)
Discussion started by: ROCK_PLSQL
14 Replies

3. UNIX for Dummies Questions & Answers

How to move gz files from one source directory to destination directory?

Hi All, Daily i am doing the house keeping in one of my server and manually moving the files which were older than 90 days and moving to destination folder. using the find command . Could you please assist me how to put the automation using the shell script . ... (11 Replies)
Discussion started by: venkat918
11 Replies

4. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

5. UNIX for Dummies Questions & Answers

Zip all files in a directory and move to another directory

Hi, need to zip all files in a directory and move to another directory after the zip.. i am using this one but didnt help me... zip -r my_proj_`date +%Y%m%d%H%MS`.zip /path/my_proj mv in_proj_`date +%Y%m%d%H%M%S`.zip /path/source/ i am trying to zip all the files in my_proj... (0 Replies)
Discussion started by: dssyadav
0 Replies

6. Shell Programming and Scripting

Move the latest or older File from one directory to another Directory

I Need help for one requirement, I want to move the latest/Older file in the folder to another file. File have the datetimestamp in postfix. Example: Source Directory : \a destination Directory : \a\b File1 : xy_MMDDYYYYHHMM.txt (xy_032120101456.txt) File2: xy_MMDDYYYYHHMM.txt... (1 Reply)
Discussion started by: pp_ayyanar
1 Replies

7. Shell Programming and Scripting

Need to move the directory

hello guys I have a folder named "XYZ". It consist many sub-folders and subfolder contain several files. there may be abc.dat in each subfolder. Now i want to separate subfolders on following conditions- if abc.dat > 1kb (size) move all subfolders to a new folder. I tried this:- find /XYZ... (1 Reply)
Discussion started by: infiant
1 Replies

8. Shell Programming and Scripting

Move a file from windows directory to unix directory

Move a file from windows directory to unix directory, is this possible? if it is, can someone help me on this? Thanks! God bless! (1 Reply)
Discussion started by: kingpeejay
1 Replies

9. UNIX for Dummies Questions & Answers

Move all files in a directory tree to a signal directory?

Is this possible? Let me know If I need specify further on what I am trying to do- I just want to spare you the boring details of my personal file management. Thanks in advance- Brian- (2 Replies)
Discussion started by: briandanielz
2 Replies
Login or Register to Ask a Question