Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Commands»How To Find Files Modified in Last 30 Days in Linux

    How To Find Files Modified in Last 30 Days in Linux

    RahulBy RahulJuly 4, 20202 Mins ReadUpdated:February 12, 2021

    find is the Unix/Linux command line utility used for searching files across the file system. Sometimes we need to search files modified in last few days. Assume you have modified multiple files in your application and forgot to keep track of the modified files. In that case, find command provides you an option to search files based on their modification. You can also search the files modified before X days.

    Use -mtime option with the find command to search files based on modification time followed by the number of days. Number of days can be used in two formats.

    1. Use + with number of days to search file modified older that X days
    2. Use – with number of days to search file modified in last X days

    The below examples will help you to understand the search for files based on modification time.

    Find files modified in last X days

    Use below command to search all files and directories modified in last 30 days. Here dot (.) is used to search in current directory. And -30 defines to search files modified in last 30 day. Change this number with your search requirements.

    find . -mtime -30
    

    You can also customize search based on file type. Use -type followed with -f (file) or -d (directory). Below command will search for files only.

    find . -type f -mtime -30
    

    Find files modified before X days

    The below command will search all files and directories modified before 30 days. Here dot (.) is used to search in current directory. And +30 defines to search files modified before 30 day. Change this number with your search preferences.

    find . -mtime +30
    

    Customize search pattern to search for files only using -type f. Or use -type d to search for directories.

    find . -type f -mtime +30
    

    Conclusion

    This tutorial described you to find files based on modification days. You can also use more options with find command to filter more.

    command find search
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleDocker-compose for MySQL with phpMyAdmin
    Next Article How to Secure MongoDB with User Authentication

    Related Posts

    How to Search Recently Modified Files in Linux

    2 Mins Read

    Bash Printf Command

    Updated:December 23, 20212 Mins Read

    (Resolved) -bash: /bin/mv: Argument list too long

    Updated:January 13, 20222 Mins Read

    tee Command in Linux with Examples

    Updated:July 1, 20224 Mins Read

    How to Scan Open Ports with Nmap

    5 Mins Read

    Handling filenames with spaces in Linux

    3 Mins Read

    2 Comments

    1. Walter Byrd on March 2, 2022 6:18 pm

      All of this was broken with systemd.

      $ find . -mtime -30 days
      find: paths must precede expression: days
      Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path…] [expression]

      Reply
    2. Alex on February 12, 2021 3:31 pm

      Rahul, it was a great help. Thanks. Alex

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How To Install Docker on Ubuntu 22.04
    • How to Install Bower on Ubuntu 22.04 & 20.04
    • How to run “npm start” through Docker
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.