Use a for loop to go through the filenames in the directory. In this version, only loop through the filenames that do not have a ".old" extension

Inside the loop, rename the file to the new name.

any idea how to do this please?

link|improve this question
2  
That reads an awful lot like a homework assignment. – garyjohn Nov 22 '11 at 1:48
feedback

2 Answers

You need to replace what's between do and done this is an example of how you can use $f

#!/bin/sh

cd /data
list=`ls -rt`

for f in $list
do
    c=`grep -c or=90 $f`
    if [ "$c" -gt "0" ]; then    
        echo "file is $f and it has $c"
    fi
done

cd -
link|improve this answer
feedback

As this isn't a homework question, and you just want to know the best way to do this, here is a way to do it with find:

find /startfolder -not -name '*.old' -exec mv {} newname_{} \;

This will get all files that don't have the suffix 'old' and rename them with the prefix newname_

No for loop required.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.