How to Find Last Modified Files in Linux

1. Use the “find” command:

The “find” command is a powerful tool for finding files in Linux. To find the last modified files in a directory, use the following command:

find /path/to/directory -type f -printf ‘%T@ %p\n’ | sort -n

This command will search the specified directory and its subdirectories for files and print out the last modified time and the file path. The output will be sorted in ascending order, so the last modified files will be at the bottom.

2. Use the “ls” command:

The “ls” command is a simple way to list the contents of a directory. To find the last modified files in a directory, use the following command:

ls -lt /path/to/directory

This command will list the contents of the specified directory in descending order of last modified time. The last modified files will be at the top of the list.

3. Use the “stat” command:

The “stat” command is a powerful tool for displaying file information. To find the last modified files in a directory, use the following command:

stat -c ‘%y %n’ /path/to/directory/*

This command will display the last modified time and the file name for all files in the specified directory. The output will be sorted in ascending order, so the last modified files will be at the bottom.
[ad_1]

Find last modified files in linux; Through this tutorial, we will learn how to find modified files in last 1, 2, 5, 30 … N days and 1, 2, 5, 30 … N minutes in Linux.

How to Find Last Modified Files in Linux

Use the following commands to find modified files in last 1, 2, 5, 30 … N days and 1, 2, 5, 30 … N minutes in Linux:

  • Find files modified in last 2 days Linux
  • Find files modified in last 5 days Linux
  • Find files modified in last 30 days Linux
  • Find files modified in last 5 minutes Linux
  • Find files modified in last 30 minutes Linux

Find files modified in last 2 days Linux

Use the following command to find files modified in last 2 days in linux:

find /directory/path/ -mtime -2 -ls

Find files modified in last 5 days Linux

Use the following command to find files modified in last 5 days in linux:

find /directory/path/ -mtime -5 -ls

Find files modified in last 30 days Linux

Use the following command to find files modified in last 30 days in linux:

find /directory/path/ -mtime -30 -ls

Find files modified in last 5 minutes Linux

Use the following command to find files modified in last 5 minutes in linux:

find myapp/ -type f -mmin -5

Find files modified in last 30 minutes Linux

Use the following command to find files modified in last 30 minutes in linux:

find myapp/ -type f -mmin -30

Conclusion

Through this tutorial, we have learned how to find modified files in last 1, 2, 5, 30 … N days and 1, 2, 5, 30 … N minutes in Linux.

Recommended Linux Tutorials

[ad_2]

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

GSTIN is 03EGRPS4248R1ZD.

Contact
Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00