![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to listout the files based on group by the date...? | psiva_arul | UNIX for Dummies Questions & Answers | 3 | 04-21-2008 09:03 AM |
| Traversing thru dirs and deleting files based on date | ravi2082 | Shell Programming and Scripting | 5 | 07-18-2007 04:28 PM |
| Remove files based on date | hshapiro | UNIX for Dummies Questions & Answers | 4 | 12-09-2005 12:21 PM |
| script to view files based on date | krahuliyer | Shell Programming and Scripting | 6 | 10-05-2005 04:51 AM |
| Moving files based on creation date | dgoyea | UNIX for Dummies Questions & Answers | 1 | 06-28-2001 05:43 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Count of files based on date?
Hi Friends,
Can anyone help me with this: To get the count of files that are existing in a directory created on a perticular date like in the example (01/08) .(having same pattern for the filename) ex: FileName Creted Date FILE001 01/08/2007 FILE005 01/06/2007 TXT003 01/08/2007 FILE005 01/08/2007 I need count i.e "2" (FILE001 and FILE005 created on 01/08) I have used ls -l | grep -c ^- It is retrieving all the files in the directory, Thanks in advance Sam ![]() |
|
|||||
|
If you know the date, and are running manually, you can just grep for the date:
ls -l | grep -c "Jan 8" -Edit Better: find . -type f | xargs ls -l | grep -c "Jan 8" To prevent descent into subdirectories, just search the site for non-recursive find or something like that -/Edit Last edited by blowtorch; 01-10-2007 at 07:38 PM.. |
|
|||||
|
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]
}'
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 Code:
$./test1 Aug16 2 Jul30 3 Tayyab |
|
||||
|
Thank you very much It worked.
|
| Sponsored Links | ||
|
|