The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 01-11-2007
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 579
Maybe not your requirement, but a general solution to count number of files as per date:
Code:
$cat test1
#!/bin/ksh
ls -l | grep "^-" | awk '{
key=$6$7
freq[key]++
}
END {
for (date in freq)
        printf "%s\t%d\n", date, freq[date]
}'

Here is some sample input:
Code:
$ls -l | grep "^-"
-rw-r--r--    1 admin    other             0 Jul 30 12:31 test.cpp
-rw-r--r--    1 admin    other             3 Aug 16 07:56 test.cpp.z
-rw-r--r--    1 admin    other             0 Jul 30 12:31 test.txt
-rw-r--r--    1 admin    other             0 Jul 30 12:31 test1.cpp
-rw-r--r--    1 admin    other             3 Aug 16 07:56 test1.cpp.z

Output:
Code:
$./test1
Aug16   2
Jul30   3

Regards,
Tayyab