mv command for sub-directories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting mv command for sub-directories
# 1  
Old 11-30-2009
Bug mv command for sub-directories

All,

am quite new to unix shell scripting. my question is 'i have like 23 sub-directiries in source area and same 23 sub-directories in destination area. i want to move all the files of 1st sub-dir in source area to 1st sub-dir in destination area and so on till for 23 sub-dir's. i.e.

A B
1 . . . . . . . . . . . . . . 23 -----> 1. . . . . . . . . . . . . . . . . 23

1st sub-dir files from source -> 1st sub-dir in destination
2nd sub-dir files from source -> 2nd sub-dir in destination
.........
.........
.........
23rd sub-dir files from source -> 23rd sub-dir in destination.

can we do it with a find command with xargs with mv command or do we need to write a shell script for this?

Thanks in advance,

vijnat
# 2  
Old 11-30-2009
tar, cpio, rsync, pax and other would do that job.
# 3  
Old 11-30-2009
jlliagre,

Thanks for your reply, but as i said earlier am very new to unix, can you please help me in providing it with an example.

Thanks

vijnat
# 4  
Old 11-30-2009
Try that:
Code:
(cd A; tar cf - .)|(cd B; tar xf -)

It creates an archive of all files and directories in A and extract it on the fly in directory B.

Last edited by jlliagre; 12-01-2009 at 12:14 PM.. Reason: removed duplicate post
# 5  
Old 12-01-2009
Tools

Hi,

It worked great. Thanks for your helping hand. i appreciate it.

Thanks

vijnat
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exclude directories in FIND command

Can you please help tweak the below command to exclude all directories with the name "logs" and "tmp" find . -type f \( ! -name "*.tar*" ! -name "*.bkp*" \) -exec /usr/xpg4/bin/grep -i "user_1" /dev/null {} + >result.out bash-3.2$ uname -a SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v... (9 Replies)
Discussion started by: mohtashims
9 Replies

2. UNIX for Beginners Questions & Answers

How do I use the cut command to only print the directories?

How would I use ls -l | cut to just print the directories part from the ls -l command? (9 Replies)
Discussion started by: steezuschrist96
9 Replies

3. UNIX for Dummies Questions & Answers

Help with 'mv' command and directories

I am taking a intro to unix. This question wants me to utilize the 'mv' command to change the left diagram to the right tree diagram. For the question I am in the home directory. I just can't seem to write the command properly any help is greatly appreciated! *edit* the tree diagram I tried to... (1 Reply)
Discussion started by: qazxsw123
1 Replies

4. Shell Programming and Scripting

Run getfacl command only on directories

bash on RHEL 5.9 i have directory with several subdirectories within it. I want to find the ACL for all the directories and subdirectories within it. i need to run getfacl on all directories and subdirectories (not regular files ) in a loop. How do I do this ? Or , is there another... (1 Reply)
Discussion started by: b_pascal
1 Replies

5. UNIX for Dummies Questions & Answers

Create 2 directories in one command

Hi how can i create 2 directories in two different directories ($HOME and $PWD) with 1 command? dir 1 in $HOME and dir2 in $PWD (2 Replies)
Discussion started by: chinababy
2 Replies

6. AIX

Exclude Directories in my tar command

Hi, im having some issues after i execute the next command: tar -cvf /varios/restore/test.tar -X /jfma/test1/excludefile /jfma | gzip -c > /varios/restore/test.tar.gz this creates the desired "test.tar.gz" file, but whe i try to open it it says "tar: 0511-164 There is a media read or write... (6 Replies)
Discussion started by: blacksteel1988
6 Replies

7. UNIX for Dummies Questions & Answers

Command to stop sub directories being counted?

I'm trying to count the number of directories in a folder but I don't want to count the sub directories. So far I have this: find -type d | wc -l Is there a parameter to stop counting sub directories ? Thanks (5 Replies)
Discussion started by: Ultima
5 Replies

8. UNIX for Dummies Questions & Answers

Using grep command to find the pattern of text in all directories and sub-directories.

Hi all, Using grep command, i want to find the pattern of text in all directories and sub-directories. e.g: if i want to search for a pattern named "parmeter", i used the command grep -i "param" ../* is this correct? (1 Reply)
Discussion started by: vinothrajan55
1 Replies

9. UNIX for Dummies Questions & Answers

find command to exclude directories

Howdy I have this directory structure ... eep eepaptest eepfatest eepgltest eep.old eeppoptest ehf ehfaptest ehfgltest ehp ehpgltest I want to find files in these directories, but I want to exclude eep, ehf & ehp. Cany anyone help with the correct command ?? (1 Reply)
Discussion started by: SmurfGGM
1 Replies

10. UNIX for Dummies Questions & Answers

command to list a only sub-directories

provide me the command to list all the subdirectories from the /home (1 Reply)
Discussion started by: mail2sant
1 Replies
Login or Register to Ask a Question