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 a lot of files again ajp7701 Shell Programming and Scripting 11 03-31-2008 04:36 PM
rename files help piltrafa UNIX for Dummies Questions & Answers 2 10-04-2007 06:47 AM
trying to rename the files in dir hankooknara Shell Programming and Scripting 8 07-02-2007 12:36 AM
How to rename files? CompuTelSystem UNIX for Dummies Questions & Answers 9 05-14-2002 12:28 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-24-2003
Registered User
 

Join Date: Aug 2003
Location: Austria
Posts: 5
Rename a number of files using grep

Hi all,

I'm trying to rename a directory of html-files:

index.php?page=start

should become

start.html

I've lost track of all the pipes and brackets and decided I need some help ;-)

Many thanks.
Forum Sponsor
  #2  
Old 11-24-2003
linuxpenguin's Avatar
Registered User
 

Join Date: May 2002
Location: India
Posts: 295
I am sorry, but I do not quite understand your question.
rename: the command is mv (be it directory or file


if you want to rename multiple files, you need a loop, something like

for i in `ls `
do
.....
done
__________________
War doesnt determine who is right, it determines who is left
  #3  
Old 11-24-2003
Registered User
 

Join Date: Aug 2003
Location: Austria
Posts: 5
Sorry for being confusing.

I have multiple files in 1 directory, they are called:

index.php?page=start
index.php?page=info
index.php?page=contact
etc...

And I want to rename them all into

start.html
info.html
contact.html
etc...

thanks again.
  #4  
Old 11-24-2003
oombera's Avatar
Registered User
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
See if this works:

for i in `ls index*`; do
mv $i `echo $i | awk -F= '{print $2'}`.html;
done
  #5  
Old 11-24-2003
Registered User
 

Join Date: Aug 2003
Location: Austria
Posts: 5
That worked
I'm heading for the man pages now to find ot why ;-)

Thanks a lot.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:01 AM.


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

Content Relevant URLs by vBSEO 3.2.0