The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
rename multiple files antointoronto Shell Programming and Scripting 13 03-20-2008 06:16 AM
how to rename multiple files with a single command tayyabq8 Shell Programming and Scripting 5 03-18-2008 12:04 PM
How to rename multiple files with a common suffix er_ashu UNIX for Dummies Questions & Answers 1 09-28-2007 07:52 AM
Rename part of multiple files sajjad02 Shell Programming and Scripting 4 02-22-2005 09:30 AM
Rename multiple files luiz_fer10 UNIX for Dummies Questions & Answers 7 06-11-2002 05:06 AM

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-14-2000
Registered User
 

Join Date: Nov 2000
Posts: 5
I have a number of files

/u01/PROD/arch.PROD.1_1
/u01/PROD/arch.PROD.1_2
/u01/PROD/arch.PROD.1_3

I would like a simple method for moving/renaming them

/u01/TEST/arch.TEST.1_1
/u01/TEST/arch.TEST.1_2
/u01/TEST/arch.TEST.1_3

Note the only thing that changes is the PROD to TEST, in file and dir name.

I need to this in a script, so loops are fine, will be run via cron, the file numbers change daily. They will not always have the exact _1, _2, _3, this is an incremental number.

Any help?
Forum Sponsor
  #2 (permalink)  
Old 11-14-2000
PxT's Avatar
PxT PxT is offline
Registered User
 

Join Date: Oct 2000
Location: Sacramento, CA
Posts: 905
Code:
#!/bin/ksh

cd /u01/PROD
for file in arch*; do

newfile=`echo $file | sed 's/PROD/TEST/'`
mv $file ../TEST/$newfile

done

This will rename every *PROD* file in the PROD directory to a corresponding *TEST* name in the TEST directory.


HTH

[Edited by PxT on 11-14-2000 at 11:42 AM]
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:27 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0