Here's a solution with find
+ awk
find . -maxdepth 1 -type f -printf '%TY-%Tm-%Td\n' | awk '{array[$0]+=1}END{ for(val in array) print val" "array[val] }'
Essentially what happens is that we find all regular files and print their modification time as specified by the %T
format , and then awk
takes over , and counts each line using associate arrays . the END{}
statement uses for
loop to go through all the elements in the associated array, and print key + array[key] contents ( which is the date + count ).
You may want to use sort
to organize the output , particularly sort -k 1
based on column 1 (which is date), but that is optional. Also -maxdepth 1
will check for files only in the current folder. If you want to find files in subdirectories as well, remove -maxdepth 1
part.
Sample output
$ find . -maxdepth 1 -type f -printf '%TY-%Tm-%Td\n' | awk '{array[$0]+=1}END{ for(val in array) print val" "array[val] }'
2015-09-29 1
2016-04-06 2
2016-04-07 10
2016-04-08 2
2015-11-05 2
2016-04-22 2
2016-04-23 6
2016-04-24 1
2015-11-21 2
2015-11-22 2
109294
and109294