Deleting old files

Hi,

I have a directory which contains files.This Directory keeps getting in new files from time to time.I want to maintain only 15 files in that directory at any time and the old files should be deleted.

Eg:

Directory 'c' @'a/b/c contains:
1_a
2_a
3_a...

I want to delete all the old files and maintain only 15 such files.Please note the title of the files is in this format "1_a"...

I know I have to use the command :
find /a/b/c -type f -name '*.a' -mtime +10 -exec rm {} \;

I just want toincorporate that 15 files limit in that directory.

Thanks.

ls -rt | tail +16

Should give you a list of files excluding the most recent 15 in any particular directory.

I know it can be acheived in a simpler way, but still you can give this a try:

ls -tr *_a | xargs ./scr

Code for ./scr goes here:

#! /bin/ksh
tai=0
count=$#
let tai=$count-15
if [[ $tai -gt 0  ]] then
ls -tr *.txt | head -${tai} | xargs rm
else
echo "No action required..."
fi

Any correction would be highly appreciated.

Regards,
Tayyab