The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
grep unix.com with google



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-30-2009
Registered User
 

Join Date: Nov 2009
Posts: 3
Smile 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 (permalink)  
Old 11-30-2009
ɹǝsn sıɹɐlosuǝdo
 

Join Date: Dec 2007
Location: Paris
Posts: 1,658
tar, cpio, rsync, pax and other would do that job.
  #3 (permalink)  
Old 11-30-2009
Registered User
 

Join Date: Nov 2009
Posts: 3
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 (permalink)  
Old 11-30-2009
ɹǝsn sıɹɐlosuǝdo
 

Join Date: Dec 2007
Location: Paris
Posts: 1,658
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 (permalink)  
Old 12-01-2009
Registered User
 

Join Date: Nov 2009
Posts: 3
Cool

Hi,

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

Thanks

vijnat
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Command to list only files omit directories. Veenak15 Shell Programming and Scripting 5 07-09-2009 08:13 AM
find command to exclude directories SmurfGGM UNIX for Dummies Questions & Answers 1 07-10-2008 08:29 AM
command to list a only sub-directories mail2sant UNIX for Dummies Questions & Answers 1 05-09-2008 11:11 AM
Command for delete the directories which are older than 7 days sridhar sivakot HP-UX 1 02-15-2008 09:11 AM
How to see only directories using ls command ravikirankethe UNIX for Dummies Questions & Answers 6 11-13-2006 06:17 AM



All times are GMT -4. The time now is 12:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0