Hi ,
I'm a guy new to Unix.
I need help to delete files in a folder on a certain criteria :-
The problem is that i donna know the names of the files.
they are generated auto. by a diff program.
the target is just to retain the latest 3 files.
like its a sought of daily proces -- so if a script can be written for that.
like if i have files in my folder (in acsending order of timestamp -- this is imp).
a1 : created 10:45
a2 : created 10:46
a3 : created 10:47
a4 : created 10:48
a5 : created 10:49
-- i just need to retain the last 3 files (a3 , a4 , a5)
i.e. -- only the latest 3 files and delete rest all the files.
it should not do anything if there are 3 or less than 3 files in the folder.
Can anyone please help me out ..
Regards,