Delete Solaris files older than a certain date and time
It is sometimes useful to delete files conditionally based on their age. This recipe describes a procedure for deleting aged files using the UNIX find command.
The find command has a -newer expression which compares the found files against a reference file. It returns files with a modification time newer than the reference file. To find older files, preceed the -newer expression with the negation operator !.
If you do not have a file to use with an appropriate timestamp, you can create a file with this recipe: Create/modify a UNIX file with an arbitrary timestamp.
Given the reference file /tmp/timeref, you can find all older files in the current working directory and beneath using the following command:
find . ! -newer /tmp/timeref -exec ls -l {} \; | more
This command is safe and will only provide a long listing of the target files, showing the files one page at a time. Using this command, you can make sure that the command syntax is correct before performing the irreversible deletion.
Once you are comfortable with the find syntax, you can change to command to cause deletion:
find . ! -newer /tmp/timeref -exec rm {} \;
Be very careful using this command. There is no easy way to undelete files in UNIX. Using the long file list version of this command first provides a great deal of safety since you can see exactly what will happen. Changing to a directory and performing the find command within it using the . as the path provides some additional protection from mistyping the path.








Johneedshelp said on July 31, 2010
im using windows is that alright??? anybody know?? how to del the NASL file.. it keep running in my recycle bin and i can’t shut off my pc.. it keeps deleting a file of out of no where.. how can i solve this prob??? please email me johnlapus25@yahoo.com
Alamo said on September 21, 2010
NASL file is burnt into the memory module, can’t be deleted. Buy a new PC instl Linux on it.
Missm Bose said on November 30, 2010
Thanks..it worked..