Learn how to find and list down recently modified files in linux

Are you working with thousands of files? Do you forget the recently modified documents in Linux? but know where you have saved those files.? Then, this article is for you to identify and list down recently modified records in Linux.
The following command is helpful to identify sorted files in the reverse order of update time-
$ find /etc -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort -r
The sample output should be like this –
2016-12-22 11:10:18.2928833250 /etc/cups/subscriptions.conf
2016-12-22 11:09:18.1987314780 /etc/cups/subscriptions.conf.O
2016-12-20 10:38:47.1524556320 /etc/init.d/.depend.stop
2016-12-20 10:38:47.1524556320 /etc/init.d/.depend.start
2016-12-20 10:38:47.1524556320 /etc/init.d/.depend.boot
2016-12-19 13:28:14.3963910250 /etc/ld.so.cache
2016-12-19 13:28:05.8242856890 /etc/mailcap
2016-12-19 13:24:12.4493955340 /etc/apt/sources.list.d/rvm-ubuntu-smplayer-xenial.list
2016-12-19 13:24:12.4493955340 /etc/apt/sources.list.d/google-chrome.list
2016-12-19 13:24:12.4493955340 /etc/apt/sources.list
2016-12-19 13:24:12.4413954340 /etc/apt/trusted.gpg.d/rvm_ubuntu_smplayer.gpg
.....................................................................................
If you want to find the changed files of specific period, use the following command-
$ find -cmin -5

The above command gives the result of the file status which was last changed in 5 minutes. The sample output should be like this –
./.config/google-chrome
./.config/google-chrome/Local State
./.config/google-chrome/Default
./.config/google-chrome/Default/Cookies
./.config/google-chrome/Default/Service Worker/ScriptCache/index-dir
./.config/google-chrome/Default/Service Worker/ScriptCache/index-dir/the-real-index
./.config/google-chrome/Default/Current Session
./.config/google-chrome/Default/Cookies-journal
./.config/google-chrome/Default/Extension State/000006.log
./.config/google-chrome/Default/History-journal
./.config/google-chrome/Default/Local Storage/chrome-extension_gighmmpiobklfepjocnamgkkbiglidom_0.localstorage
./.config/google-chrome/Default/Local Storage/https_plus.google.com_0.localstorage-journal
./.config/google-chrome/Default/Local Storage/chrome-extension_gighmmpiobklfepjocnamgkkbiglidom_0.localstorage-journal
./.config/google-chrome/Default/Local Storage/https_plus.google.com_0.localstorage
./.config/google-chrome/Default/Preferences
./.config/google-chrome/Default/Local Extension Settings/gighmmpiobklfepjocnamgkkbiglidom/000085.log
./.config/google-chrome/Default/Session Storage
./.config/google-chrome/Default/Session Storage/LOG
./.config/google-chrome/Default/Session Storage/MANIFEST-000001
./.config/google-chrome/Default/Session Storage/000471.log
./.config/google-chrome/Default/Session Storage/000472.ldb
./.config/google-chrome/Default/Extension Activity
.........................................................................
Using this command, we can find the last changed files as shown below –
$ stat --printf="%y %n\n" $(ls -tr $(find * -type f))

The sample output should be like this –
2010-03-03 01:16:33.000000000 +0530 lohit_te.ttf
2016-12-16 17:50:29.791969567 +0530 examples.desktop
2016-12-19 10:43:35.372620496 +0530 Pictures/flash.png
2016-12-19 10:59:25.275474607 +0530 Pictures/flash1.png
2016-12-19 11:27:20.234186900 +0530 httpstat.py
2016-12-19 12:32:39.819805672 +0530 Downloads/ttf-telugu-fonts_0.5.11ubuntu1_all.deb
2016-12-19 13:29:33.365359204 +0530 Pictures/smplayer.png
2016-12-19 13:53:39.907705833 +0530 Downloads/girl.jpg
2016-12-20 11:32:39.271477881 +0530 Downloads/200x200.jpg
2016-12-20 12:25:55.015482441 +0530 Downloads/hockey.jpg
2016-12-20 13:56:19.596432236 +0530 Downloads/flash-player-ubuntu.jpg
2016-12-20 14:40:41.191776867 +0530 Downloads/jabrdasth.jpg
2016-12-22 10:22:42.529763492 +0530 Videos/httpstat.py
2016-12-22 10:32:30.249527866 +0530 abc
2016-12-22 10:34:46.671286096 +0530 Music/httpstat.py
2016-12-22 10:34:46.675286130 +0530 Desktop/httpstat.py
2016-12-22 12:04:14.713113283 +0530 Downloads/SMPlayer.jpg
2016-12-22 12:05:19.310933827 +0530 Downloads/rsz_smplayer.jpg
To get the list of changed directories, use the following command –
$ ls -ltc
The sample output should be like this –
drwxr-xr-x 2 tutorialspoint tutorialspoint 4096 Dec 22 12:05 Downloads
drwxr-xr-x 2 tutorialspoint tutorialspoint 4096 Dec 22 10:34 Desktop
drwxr-xr-x 2 tutorialspoint tutorialspoint 4096 Dec 22 10:34 Music
-rw-rw-r-- 1 tutorialspoint tutorialspoint 0 Dec 22 10:32 abc
drwxr-xr-x 2 tutorialspoint tutorialspoint 4096 Dec 22 10:22 Videos
-rw-rw-r-- 1 tutorialspoint tutorialspoint 155368 Dec 19 14:55 lohit_te.ttf
drwxr-xr-x 3 tutorialspoint tutorialspoint 4096 Dec 19 13:29 Pictures
-rw-rw-r-- 1 tutorialspoint tutorialspoint 10577 Dec 19 11:27 httpstat.py
drwxr-xr-x 2 tutorialspoint tutorialspoint 4096 Dec 16 19:03 Documents
drwxr-xr-x 2 tutorialspoint tutorialspoint 4096 Dec 16 19:03 Public
drwxr-xr-x 2 tutorialspoint tutorialspoint 4096 Dec 16 19:03 Templates
-rw-r--r-- 1 tutorialspoint tutorialspoint 8980 Dec 16 17:50 examples.desktop
To get the list of recently modified files in Linux using with python, use the following command –
$ find . -type f -print |
> python -c 'import os, sys; times = {}
> for f in sys.stdin.readlines(): f = f[0:-1]; times[f] = os.stat(f).st_mtime
> for f in sorted(times.iterkeys(), key=lambda f:times[f]): print f'
The sample output should be like this –
./.cache/google-chrome/Default/Cache/28b4d5c73382c76e_0
./.cache/google-chrome/Default/Cache/47603dda53f4eff9_0
./.cache/google-chrome/Default/Cache/628cf2914597e226_0
./.cache/google-chrome/Default/Cache/6abab0fdc6e1b757_0
./.cache/google-chrome/Default/Cache/edc5a146f72fc62a_1
./.cache/google-chrome/Default/Cache/e21f7099ce14a183_0
./.cache/google-chrome/Default/Cache/954cd78918e0ef94_1
./.cache/google-chrome/Default/Cache/66966ca01a40cbea_1
./.cache/google-chrome/Default/Cache/e53fd0655371a5dd_0
./.cache/google-chrome/Default/Cache/e81e30e428358e80_0
./.cache/google-chrome/Default/Cache/787db5079efa9083_0
./.cache/google-chrome/Default/Cache/17340f80011e77a5_1
./.cache/google-chrome/Default/Cache/a82652595e2c24a1_1
./.cache/google-chrome/Default/Cache/3061c4bd90e582ca_1
./.cache/google-chrome/Default/Cache/5dc7329ed9c947e5_1
./.cache/google-chrome/Default/Cache/54346d971accf6ee_1
..............................................................................................
After this article, you will be able to learn how to Find and list down recently modified files in Linux.. In our next articles, we will come up with more Linux based tricks and tips. Keep reading!