The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Need help renaming files bbbngowc UNIX for Dummies Questions & Answers 5 04-23-2008 02:08 PM
Renaming Files abch624 Shell Programming and Scripting 2 03-20-2008 12:54 AM
Renaming files Tygoon UNIX for Dummies Questions & Answers 7 01-06-2008 10:59 PM
renaming files systemsb UNIX for Dummies Questions & Answers 3 05-25-2006 12:56 AM
renaming files raguramtgr UNIX for Dummies Questions & Answers 4 09-21-2004 10:57 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-04-2008
jxh461 jxh461 is offline
Registered User
  
 

Join Date: Jun 2002
Posts: 49
renaming files

I have a list of files named ab_*.csv

I would like to remane them all by removing the ab_ and have *.csv

I did the following but I am surely missing something.

/* wrong script */
for i in `ls -1 ab_*`; do mv ab_$i $i; done

Thanks in advance.
  #2 (permalink)  
Old 02-04-2008
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
Quote:
Originally Posted by jxh461 View Post
I did the following but I am surely missing something.
Yes you are...

Code:
bash-3.00# ls
ab_1.csv  ab_2.csv  ab_3.csv  ab_4.csv

bash-3.00# for i in ab_*.csv; do
> echo mv $i ${i#*_}
> done
mv ab_1.csv 1.csv
mv ab_2.csv 2.csv
mv ab_3.csv 3.csv
mv ab_4.csv 4.csv
Check the Parameter Expansion section of the man page of bash/ksh for the explanation.
Sponsored Links
Closed Thread

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 On



All times are GMT -4. The time now is 07:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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