Go2Linux | Linux Operating System

A site dedicated to: Linux Operating System

Find files modified in the last n days, or today | useful with folders

Date: 2011-04-16 00:00:00 -0400

Introduction

If you wan to find files or directories, that were last modified in the last n days or just today, it is really easy to do in Linux.

How to find files last modifies today

Use the find command to do this

find -maxdepth 1 -type f -mtime 1
  • maxdepth: will tell find to only search in the current folder
  • type: will tell find to only list files and not directories
  • mtime: will tell find to only list the files modified in the last 24 hours

So, you can modify this command to accomplish another tasks.

Find files modified in the last 48 hours, and in current folder and one level below

find -maxdepth 2 -type f -mtime 2

Same thing with folders

find -maxdepth 2 -type d -mtime 2

If you liked this article please share it.

powered by TinyLetter

If you want to contact me in any other way, please use the contact page.