LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-20-2008, 10:23 AM   #1
neo2k
LQ Newbie
 
Registered: Aug 2008
Posts: 21

Rep: Reputation: 15
Question mulitple copy a existing directory and rename it at the end sequentially in BASH


Hi Guys,

i am trying to create a script to copy a single exisitng directory to multiple copirs and rename those copies sequentially in bash script.

for e.g.

my existing directory is Itr1_b1_w1_130 and i want to make multiple copies of this directory and this should be renamed as Itr2_b1_w1_130, Itr3_b1_w1_130....Itr40_b1_w1_130.

I know i have to use the for loop to get this work.

Any help or clues to get this work done would be really helpful.Appreciate your help.

Thanks
 
Old 08-20-2008, 10:32 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Something like this?
Code:
for i in {2..40}
do
  cp -pR Itr1_b1_w1_130 /path/to/Itr${i}_b1_w1_130
done
 
Old 08-20-2008, 10:45 AM   #3
neo2k
LQ Newbie
 
Registered: Aug 2008
Posts: 21

Original Poster
Rep: Reputation: 15
Thanks for the answer. Sorry to post in two places.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash - rename directory to overwrite existing LarsWestergren Linux - Newbie 18 04-04-2013 02:07 PM
bash - copy with a directory structure mkiler Linux - General 6 06-03-2008 08:45 AM
To rename files in a directory should I use Bash script or a Perl Script ? jamtech Programming 7 01-22-2008 11:25 PM
[SOLVED] A bash script to automatically copy all documents with directory structure thelordmule Programming 8 11-30-2007 02:30 AM
Bash script to traverse directory tree and rename files intramaweb Programming 3 10-08-2006 12:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration