How To Remove Files Older Than 1 Day Recursively

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/remove-files-older-1-day-recursively/
PINTEREST
PINTEREST
INSTAGRAM

We are decent bash scripter and not now hot to remove older files for example 1 day. rm command do not have this type of option to use easily. I think adding this type of feature make a lot of system administrators more happy.

Now we can look our solution. We will use find command to find files older than 1 day  remove them.

  • find is the command we use
  • /tmp is the directory where files resides
  • -mtime provide time option and +1 means older then one day
  • -type provides file types here we set file but we can use directory, socket etc
  • name ‘*.tmp’ filters files according to their names. we just want tmp extension files
  • And the magic resides here -delete will delete the files matching provided criterias
RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/remove-files-older-1-day-recursively/
PINTEREST
PINTEREST
INSTAGRAM

LEARN MORE  Linux Directory and File Operations

Leave a Reply

Your email address will not be published.