The UNIX and Linux Forums  

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



Thread: renaming files
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 02-04-2008
blowtorch's Avatar
blowtorch blowtorch is offline
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,325
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.
Reply With Quote