on 12-16-2008 10:50 AM
How could I delete all files older than those from 15th. a directory.
I wander about a unix command like "rm -?"(but i do not know the switches for rm)
You can use find command:
find /my_current_directory -mtime +5 -exec rm {} \;
Note
To find files created more than 5 days use -mtime +5
To find files created less than 5 days use -mtime -5
You can also specify less than one day ago ( -ctime -1 ), or exactly one day ago ( -ctime 1 ).
So, the format for the time options is:
-mtime n
-ctime n
-atime n
where n is a number of days. The following applies:
A number with no sign, for example, 3 (as in -mtime 3 or -atime 3), means the 24-hour period that ended exactly three days ago (in other words, between 96 and 72 hours ago).
A number with a minus sign refers to the period since that time. For example, -3 (as in -mtime -3) is any time between now and three days ago (in other words, between 0 and 72 hours ago).
Naturally, a number with a plus sign refers to the 24-hour period before that time. For example, +3 (as in -mtime +3) is any time more than three days ago (in other words, more than 96 hours ago).
Regards,
Jazz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Read man find and man touch,
useful switches for find:
-exec
-mtime
-newer
-name
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.