vidyadhar85, I don't get the desired ouput with your solution....
ric79, try this:
ls -la |
awk ' BEGIN{
split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", month, " ")
for (i=1; i<=12; i++) mdigit[month]=i
}
$8 ~ /:/{$8="2009"}
{
dat=$8 sprintf("%02d",mdigit[$6]) sprintf("%02d",$7)
a[dat]++
}
END{for(i in a){print i, a|"sort"}}'
ls -la |
awk ' BEGIN{
split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", month, " ")
for (i=1; i<=12; i++) mdigit[month]=i
}
$8 ~ /:/{$8="2009"}
{
dat=$8 sprintf("%02d",mdigit[$6]) sprintf("%02d",$7)
a[dat]++
}
END{for(i in a){print i, a|"sort"}}'
1) Is it possibile to avoid "2009" and get the current year?
2) The script display also "0000 1". I need to count only Files and not Directories
3) Jan Feb Mar ... what does it happen if the unix version is Italian? Is there a way to make ls printing 01 instead of Jan?
Here I use a variabale for the year and the directories are ignored now with !/^-/{next}.
For another language you have to change the month names manualy.
ls -la |
awk -v year=$(date "+%Y")' BEGIN{
split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", month, " ")
for (i=1; i<=12; i++) mdigit[month]=i
}
!/^-/{next}
$8 ~ /:/{$8=year}
{
dat=$8 sprintf("%02d",mdigit[$6]) sprintf("%02d",$7)
a[dat]++
}
END{for(i in a){print i, a|"sort"}}'
#!/bin/sh
ls -la |
awk -v year=$(date "+%Y") ' BEGIN{
split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", month, " ")
for (i=1; i<=12; i++) mdigit[month]=i
$mydate="2009"
}
!/^-/{next}
$8 ~ /:/{$8=year}
{
dat=$8 sprintf("%02d",mdigit[$6]) sprintf("%02d",$7)
a[dat]++
}
END{for(i in a){print i, a|"sort"}}'