i need help for unix

May 5, 2011 at 04:24:15
Specs: Windows XP
Hello,

I need a script that will change the names of all files in a folder by removing the last "X" number of characters, like


bob_0607.csv.error
bob_1111.csv.error
bob_4705.csv.error
bob_4707.csv.error
to

bob_0607.csv
bob_1111.csv
bob_4705.csv
bob_4707.csv.

Any help would be greatly appreciated.
GunGun


See More: i need help for unix

Report •

#1
May 5, 2011 at 06:59:34
Remove the .error at the end of the string:

#!/bin/ksh

# cd to_your_dir

ls -1 bob*.error|while read file
do
   mv $file $(echo "$file"|sed 's/\.error$//')
done


Report •
Related Solutions


Ask Question