To find and delete a file that is more than one hour old in a UNIX shell, you can use the find
command with the -ctime
and -delete
options.
For example, the following command will find and delete all files in the current directory that are more than one hour old:
find . -ctime +1 -delete
The .
specifies the current directory, and the -ctime +1
option searches for files that were last changed more than one hour ago. The -delete
option deletes the matching files.
You can also use the -mtime
option to search for files based on their last modification time instead of their last change time:
find . -mtime +1 -delete
This will find and delete all files in the current directory that were last modified more than one hour ago.
Keep in mind that the find
command has many options for filtering the files it searches for, so you can fine-tune the search to meet your specific needs. For more information on the find
command and its options, you can refer to the documentation or use the man
command to view the manual pages.