shell - Deleting log directories of a particular timestamp in UNIX -
i want delete directories 5 days old, based on directory name, instead of unix timestamp. let assume directories created test_2013-05-20-12:23:43
, on.
i want delete directories 5 days older, i.e before 16th.
is possible do?
if not specific file name criteria use this
find /path/to/files* -mtime +5 -exec rm {} \;
note there spaces between rm, {}, , \;
explanation
the first argument path files. can path, directory, or wildcard in example above. recommend using full path, , make sure run command without exec rm make sure getting right results. second argument, -mtime, used specify number of days old file is. if enter +5, find files older 5 days. third argument, -exec, allows pass in command such rm. {} \; @ end required end command.
read link more info
Comments
Post a Comment