cancel
Showing results for 
Search instead for 
Did you mean: 

How could I delete all older than those from 15th. de files in a directory

Former Member
0 Kudos

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)

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (1)

Answers (1)

Former Member
0 Kudos

Read man find and man touch,

useful switches for find:

-exec

-mtime

-newer

-name