Dear All,
Please help !
i ham having 300 file with E.G. PMC1_4567.arc in seq. like PMC1_4568.arc,PMC1_4569.arc ...n and so on.. i want all those file to be rename like PMC_4567.arc ,PMC_4568.arc .. mean i want to remove 1 from first file name ..
pls help..
I am not sure if it can be done in a single unix command, but this small script may help you
#!/usr/bin/ksh
for k in PMC*.arc
do
newfilename=`echo $k | sed 's/1//g'`
cp $k $newfilename && rm $k
done
Thanks Dear it is working fine. but it is also remove one more char. form line
like PMC1_194_732756742.arc to PMC_94_732756742.arc here i need PMC1 will be rename by PMC only in next where _194_ need to be same as shown here
try this,
ls PMC1*.arc | while read k; do cp $k `echo $k |sed 's/\(.*\)1_\(.*\).arc/\1_\2\.arc/g'` && rm $k; done
moon_22
November 9, 2010, 12:27am
5
thanks but still my problem is not resolve as i want PMC1_194_732756742.arc to PMC_1_194_732756742.arc here it is PMC_194_732756742.arc
can any one help me?
Hi,
In your previous post it was not mentioned.
try this,
ls PMC1*.arc | while read k; do cp $k `echo $k |sed 's/\(.*\)1_\(.*\).arc/\1_1_\2\.arc/g'` && rm $k; done
Hi praveen thansk it is done only few rows which has no like PMC1_241_.arc ,PMC1_251_*.arc,PMC1_261_ .arc
get repalce with PMC_1_24_*.arc rest all are ok thanks