How to use find command to find files created on a specific date on GNU / Linux?
The easiest and most readable way but not most efficient ) especially for big hard disks with a lot of files not the best way) to do it is via:
find ./ -type f -ls |grep '12 Oct'
Example: To find all files modified on the 12th of October, 2017:
find . -type f -newermt 2017-10-12 ! -newermt 2017-10-13
To find all files accessed on the 29th of september, 2008:
$ find . -type f -newerat 2015-09-29 ! -newerat 2015-09-30
Or, files which had their permission changed on the same day:
$ find . -type f -newerct 2015-09-29 ! -newerct 2015-09-30
If you don't change permissions on the file, 'c' would normally correspond to the creation date, though.
Another more cryptic way but perhaps more efficient to find any file modified on October 12th,2017, would be with below command:
find . -type f -mtime $(( ( $(date +%s) – $(date -d '2017-10-12' +%s) ) / 60 / 60 / 24 – 1 ))
You could also look at files between certain dates by creating two files with touch
touch -t 0810010000 /tmp/f-example1
touch -t 0810011000 /tmp/f-example2
This will find all files between the two dates & times of the 2 files /tmp
find / -newer /tmp/f-example1 -and -not -newer /tmp/f-exampl2
How to Find Files with a certain size on GNU / Linux?
Lets say you got cracked and someone uploaded a shell php file of 50296 bytes a , that's a real scenario that just happened to me:
root@pcfreak:/var/www/blog/wp-admin/js# ls -b green.php
green.php
root@pcfreak:/var/www/blog/wp-admin/js# ls -al green.php
-rw-r–r– 1 www-data www-data 50296 окт 12 02:27 green.phproot@pcfreak:/home/hipo# find /var/www/ -type f -size 50296c -exec ls {} ;
/var/www/blog/wp-content/themes/default/green.php
/var/www/blog/wp-content/w3tc/pgcache/blog/tag/endless-loop/_index.html
/var/www/blog/wp-content/w3tc/pgcache/blog/tag/common/_index.html
/var/www/blog/wp-content/w3tc/pgcache/blog/tag/apacheroot/_index.html
/var/www/blog/wp-content/w3tc-bak/pgcache/blog/tag/endless-loop/_index.html
/var/www/blog/wp-content/w3tc-bak/pgcache/blog/tag/common/_index.html
/var/www/blog/wp-content/w3tc-bak/pgcache/blog/tag/apacheroot/_index.html
/var/www/pcfreakbiz/wp-includes/css/media-views.css
More helpful Articles
Tags: command, created, Date, Files, find, specific