I have a directory containing a high number of files (like logs for every day of the year).
I would like to remove all files created before let's say 22/11. How can I achieve that ? Must I use find
then exec -rm
? I'm using ksh.
Shell – Remove all files created before a certain date
filesfindkshshell
Best Answer
Using
find
is still the preferred way of deleting files. See http://mywiki.wooledge.org/UsingFind for more.One way of doing this is to create a file with the time-stamp in it. e.g
Now delete the files GNU
find
(assuming in the current directory) that match the time-stamp e.g:or non GNU find