Linux find files changed today

linux-notes.org

Иногда, нужно найти все измененные файлы или папки в Unix/Linux ОС и в моей статье «Поиск последних измененных файлов/папок в Unix/Linux» я расскажу как это сделать.

Чтобы найти все файлы, которые были изменены с момента определенного времени (т.е. час назад, день назад, 24 часа назад и так далее) в Unix и Linux имеется команда find и она очень пригодиться для таких целей.
Чтобы найти все файлы, которые были изменены в течение последних 24 часов (последний полный день) в текущем каталоге и в его подкаталогах, используйте:

Опция «-mtime -1» сообщает команде find искать модифицированные файлы за последние сутки (24 часа).
Опция «-print» сообщает «find» выводить файлы и их пути (где они лежат) и данную команду можно заменить на «-ls» если нужно вывести подробную информацию о файле.

Примеры:

Например нужно найти файлы, что были изменены за последние 30 минут в папке /home/captain:

И приведу пример подобного, но для папки:

Например нужно найти измененные файлы за 5 дней, но не включать в поиск вчерашний день (за последний день):

Для полного счастья, можно вывести время модификации и отсортировать по нему:

Чтобы ограничить уровень вложенности, добавьте параметр «-depth». Например, поиск с уровнем вложенности не более 3 папок:

Поиск файлов в /home/captain директории (и во всех ее подпапках) которые были изменены в течение последних 60 минут, и вывести их атрибуты:

В качестве альтернативы, вы можете использовать xargs команду, чтобы достичь того же:

Поиск последних измененных файлов/папок в Unix/Linux завершен.

Добавить комментарий Отменить ответ

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.

Источник

How to Find Recent or Today’s Modified Files in Linux

In this article, we will explain two, simple command line tips that enable you to only list all today’s files.

One of the common problems Linux users encounter on the command line is locating files with a particular name, it can be much easier when you actually know the filename.

However, assuming that you have forgotten the name of a file that you created (in your home folder which contains hundreds of files) at an earlier time during the day and yet you need to use urgently.

Читайте также:  Как включить антивирусник windows

Below are different ways of only listing all files that you created or modified (directly or indirectly) today.

1. Using the ls command, you can only list today’s files in your home folder as follows, where:

  1. -a – list all files including hidden files
  2. -l – enables long listing format
  3. —time-style=FORMAT – shows time in the specified FORMAT
  4. +%D – show/use date in %m/%d/%y format

Find Recent Files in Linux

In addition, you can sort the resultant list alphabetically by including the -X flag:

You can also list based on size (largest first) using the -S flag:

2. Again, it is possible to use the find command which is practically more flexible and offers plenty of options than ls, for the same purpose as below.

  1. -maxdepth level is used to specify the level (in terms of sub-directories) below the starting point (current directory in this case) to which the search operation will be carried out.
  2. -newerXY , this works if timestamp X of the file in question is newer than timestamp Y of the file reference. X and Y represent any of the letters below:
    1. a – access time of the file reference
    2. B – birth time of the file reference
    3. c – inode status change time of reference
    4. m – modification time of the file reference
    5. t – reference is interpreted directly as a time

This means that, only files modified on 2016-12-06 will be considered:

Find Today’s Files in Linux

Important: Use the correct date format as reference in the find command above, once you use a wrong format, you will get an error as the one below:

Alternatively, use the correct formats below:

Find Todays Modified Files in Linux

You can get more usage information for ls and find commands in our following series of articles on same.

In this article, we explained two important tips of how to list only today’s files with the help of ls and find commands. Make use of the feedback form below to send us any question(s) or comments about the topic. You can as well inform us of any commands used for the same goal.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

Find Files that are Modified Today (or Since Certain Time Ago) in Unix & Linux

T o find all files that was modified since a specific time ago (i.e an hour ago, a day ago, 24 hours ago, a weeks ago and so on) in Unix and Linux environment, the find command will come in handy. The command syntax is:

To find all files modified in the last 24 hours (last full day) in current directory and its sub-directories:

Flag -mtime -1 option tells find command to look for files modified in the last day (24 hours). Flag -print option will cause find command to print the files’ location. -print can be replaced with -ls if you want a directory-listing-type response.

Читайте также:  Windows error green screen

To find all files modified in the last 24 hours (last full day) in a particular specific directory and its sub-directories:

The command is basically the same with the earlier command, just that now you no need to cd (change directory) to the directory you want to search.

To find all files with regular file types only, and modified in the last 24 hours (last full day) in current directory and its sub-directories:

To find all files that are modified today only (since start of day only, i.e. 12 am), in current directory and its sub-directories:

The first command can be modified to specify other date and time, so that the commands will return all files that have changed since that particular date and time.

Источник

How to find recently modified files in Linux

If you are working on thousands of files a day and want to find a list of files that have been modified recently in a directory for certain purposes, this can be done easily using the find command.

The find command is used to search or locate files based on various criteria such as timestamp, file type and file permissions in Linux.

Please refer to our previous article on how to find a directory size in Linux.

In this article, we have included 13 examples for locating files based on timestamp and I hope this article will meet your needs.

In Linux, a file contains three timestamps, which are updated when a file is accessed or modified or replaced.

Types of file timestamps:

  • atime: access time or Last access time
  • mtime: modify time or Last modification time
  • ctime: change time or Last change time

Read the below explanation for better understanding about timestamp.

  • atime/amin: The last time the file was accessed by some command or application.
  • mtime/mmin: The last time the file’s contents was modified.
  • ctime/cmin: The last time the file’s attribute was modified.

How to check all timestamps of a file?

It can be easily seen using ‘stat’ command, which displays all three timestamps of a file.

The common syntax is as follows:

We can use numerical arguments with ‘mtime’. Use “-mtime n” command to return a list of files that were last modified “n” hours ago.

  • +n: for greater than n
  • -n: for less than n
  • n: for exactly n

See the format below for a better understanding.

  • -mtime +10: This will find all files that were modified 10 days ago.
  • -mtime -10: It will find all files that were modified in the last 10 days.
  • -mtime 10: Use this format to find all files that were modified EXACTLY 10 days ago.

1) Sorting files & folders based on conversion time

This can be done by using the ls command with some options as shown below, which sorts the files and folders in reverse order based on the conversion time.

2) Sorting only folders based on conversion time

Use the following format to sort only folders in reverse order based on conversion time.

3) How to find only files that were modified 120 days ago

The below find command will show a list of files that were changed 120 days ago.

4) How to find only files that were modified in last 15 days

The below find command will show a list of files that have changed in the last 15 days:

Читайте также:  После обновления windows 10 синий экран при загрузке windows

5) How to find only files that were modified exactly 10 days ago

The below find command will show you a list of files that were changed exactly 10 days ago:

6) How to find only files that were modified within last 30 Mins

The below find command will show a list of files that have changed within the last 30 mins.

7) How to find only the folder’s modified in last 5 Days

This command displays only folders modified within the last 5 days.

8) How to find both Files and Folders that were modified in last 15 Days

This command displays a list of files and folders modified within last 15 days:

9) How to find modified files and folders starting from a given Date to the latest Date

This command allows you to find a list of files and folders that have been modified starting from a given date to the latest date:

10) How to find all files and folders modified in the Last 24 Hours

Alternatively, you can use an easy-to-understand format like the one below to find files and folders that have changed over the past 24 hours.

11) How to find a list of “sh” extension files accessed in the Last 30 Days

This command helps you to find a list of files with “sh” extension accessed in the last 30 days.

12) How to find files that have been modified over a period of time

The below command shows a list of files that have changed in the last 20 minutes.

13) How to find a list of files created Today

This command enables you to find a list of files created today:

Closing Notes

This article explained how to find recently modified files & folders in Linux.

If you have any questions or feedback, feel free to comment below.

Источник

Как найти недавно модифицированные файлы в Linux

Зачастую требуется найти файлы, которые были модифицированы/созданы недавно, или за какой-либо промежуток времени. Например, администратор изменял настройки системы, но забыл, где он их сохранил. Или вы хотите проверить изменялись ли, и как, ваши файлы. Если вам необходимо найти недавно измененные файлы в linux, это можно сделать с помощью команды find.

Чтобы найти недавно модифицированные файлы, отсортированные в обратном порядке (то есть файл, измененный последним, будет показан первым), используется команда вида:

Вышеприведенная команда сортирует файлы в /etc (и поддиректориях) в обратном порядке по времени их изменения, и выводит отсортированный список вместе с их расположением в файловой системе и временем последнего изменения. Если вы также хотите проверить директории, опустите опцию «-type f».

Поиск файлов, которые были модифицированы в последние 60 минут в директории /target_directory и во всех ее поддиректориях:

Поиск файлов, которые были модифицированы в последние 2 дня в директории /target_directory и во всех ее поддиректориях:

Поиск файлов, которые были модифицированы в последние 2 дня в директории /target_directory и ее поддиректориях глубиной до 3 уровня:

Вы также можете задать диапазон времени модификации. Поиск файлов, которые были модифицированы в последние 7 дней, но не позднее чем 3 дня назад:

Все эти команды выводят только путь к найденным файлам. Вы можете также детализировать вывод информации с помощью опции «-exec».
Поиск файлов в директории /target_directory (и во всех ее поддиректориях), которые были модифицированы в последние 60 минут и вывод атрибутов файлов:

В качестве альтернативы вы можете использовать для этого команду xargs:

Обратите внимание, что эти команды найдут также файлы, созданные в заданный промежуток времени.

Источник

Оцените статью