How to Search Recently Modified Files in Linux

This tutorial will help you to find recently modified files in Linux via command line .

The find command allows us to define duration in Minutes or Days. The minutes are define with -mmin and the days value can be defined with -mtime

You can also define the search criteria to find files modified within or before specified duration. For example, to search files modified before, use “+” (positive) with duration (eg: +1, +24 etc). To search files modified within duration use “-” (negative) sign with duration value (eg: -1, -24) etc.

Find All Modified Files Less Than Time

  1. Modified within 10 Minutes:- Search all files modified within 10 minutes in the current directory. Use -mmin -10 means the files last modified less than 10 minutes.
    find . -type f -mmin -10 
    
  2. Modified within 2 Hours:- Find all files modified within 2 hours in the current directory. Use -mmin -120 means the files last modified less than 120 minutes ie equal to 2 hours.
    find . -type f -mmin -120 
    
  3. Modified within 1 day:- Search all files modified within 24 hours in the current directory. To define range in days use -mtime. For example -mtime -1 means the files last modified les than 24 hours ago.
    find . -type f -mtime -1 
    

Find All Modified Files Before Time

The above example, find all file modified within specified duration. But you can also search files modified before specified duration with the help of below examples.

  1. Modified older than 10 Minutes:- Search all files modified before 10 minutes in the current directory. Use -mmin +10 option, which means find all files modified more than 10 minutes ago.
    find . -type f -mmin +10 
    
  2. Modified older than 2 Hours:- Find all files modified before 2 hours in the current directory. Use -mmin +120 options to search file modified older than 120 minutes (ie 2 hours).
    find . -type f -mmin +120 
    
  3. Modified older than 1 day:- Search all files modified more than 24 hours ago in the current directory. You can use -mtime option to define duration in days. For example -mtime +1 means find all files modified before 24 hours.
    find . -type f -mtime +1 
    

The post How to Search Recently Modified Files in Linux appeared first on TecAdmin.

files find Linux Commands TecAdmin