Date filters for the Linux find command

  • find . -ctime -3 # created in the past 3 days
  • find . -ctime +3 # older than 3 days
  • find . -ctime 3 # created exactly 3 days back
  • find . -ctime +3 -ctime -5 # created 3 – 5 days back
  • find . -newer /tmp/somefile # see somefile’s timestamp and show files newer than it
  • works great in conjunction with:
  • touch 0607090016 /tmp/somefile #i.e. 7th june, 9:00 am, 2016
  • find . -maxdepth 1 -type d -ctime +38 -exec rm -rf {} \; delete all folders older than 38 days back.
  • don’t use atime much: every directory access changes its atime, so when find traverses through it, the inode’s atime entry gets updated.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s