--When investigating the server, I want to see the largest file in a certain period. --ex. The server capacity suddenly increased, but I investigated which file was the cause, etc.
find . -type f -newermt "2020-08-31 00:00:00" -a ! -newermt "2020-09-05 23:59:59" -printf "%p %s" | sort -k 2,2
-newermt
--Newer than the specified date (>). Here, the date is after 00:00 on August 31, 2020.-a ! -newermt
--The above is denied (<=). Here, the date will be after 23:59:59 on September 5, 2020.
--When the two are combined, the period is specified as follows.
--August 31, 2020 0:00:00 <File last updated date <= September 5, 2020 23:59:59
-printf "%p %s"
--Outputs the name (full path) and file size of the file found by findsort -k 2,2
--You can specify the sort key with -k [start position], [end position]
--Here, only the second size is specified as the key.
-* Note that the result of find is only "file name file size"[Linux] Find files updated within the date range specified by the find command [Search for the corresponding file by specifying the date and time in the reverse UNIX command / find](https://linux.just4fun.biz/?%E9%80%86%E5%BC%95%E3%81%8DUNIX% E3% 82% B3% E3% 83% 9E% E3% 83% B3% E3% 83% 89 / find% E3% 81% AB% E6% 97% A5% E6% 99% 82% E3% 82% 92% E6% 8C% 87% E5% AE% 9A% E3% 81% 97% E8% A9% B2% E5% BD% 93% E3% 81% 99% E3% 82% 8B% E3% 83% 95% E3% 82% A1% E3% 82% A4% E3% 83% AB% E3% 82% 92% E6% A4% 9C% E7% B4% A2% E3% 81% 99% E3% 82% 8B # i551bc2b) newerXY option to search by specific date and time with find Detailed summary of sort command [Linux command collection] sort command (sorts text files)
Recommended Posts