-rw-r--r--+ 1 test test 17M Nov 26 14:43 test1.gz
-rw-r--r--+ 1 test test 0 Nov 26 14:44 test2.gz
-rw-r--r--+ 1 test test 0 Nov 27 10:41 test3.gz
-rw-r--r--+ 1 test test 244K Nov 27 10:41 test4.gz
-rw-r--r--+ 1 test test 17M Nov 27 10:41 test5.gz
I need output as below
DATE TOTALFILE SIZE
Nov26 2 17M
Nov27 3 17.244M
Able to determine the DATE and TOTALFILE using below script
echo " "
echo "DATE TOTALFILE"
cd /Mydir
ls -lrth | grep "^-" | awk '{
key=$6$7
freq[key]++
}
END {
for (date in freq)
printf "%s\t%d\n", date, freq[date]
}'
Can someone help me to get the size as well based on date.
Neither of these have been tested, but they should come close to what you need. I will leave the conversion of actual bytes to human readable form as an exercise for the reader. (I prefer the actual byte counts.)
If you want to use panyam's code I think you would need to change all occurrences of a[freq[key]] to a[key] and change a[freq[date]] to a[date] .