[Novalug] Re: [Ma-linux] How to get the number of files in a given directory
Clif Flynt
clif at cflynt.com
Thu Jan 10 08:52:10 EST 2008
On Thu, Jan 10, 2008 at 07:27:55AM -0500, Jay Hart wrote:
> This was really an initial exercise to determine how many files were in my
> virusmail/spammail folder, put there by amavis/spamassassin.
>
> The number of files was huge (2512 to be exact), since 11-16-07.
>
> Since I didn't know a command to do this, I logged into the box via Winscp3,
> and moved over to the spammail directory, and winscp3 gave me a count of 2512.
>
> Not the best way to determine this, but it worked.
I find that a lot of the "normal" tools fail when I need to work with
directories that have huge numbers of files in them.
My usual solution then is to start an interactive Tcl shell and do
stuff like:
# Count all files
llength [glob -type file -types f * .*]
# Count all directories
llength [glob -type file -types d * .*]
# Get the stats for the files
foreach name [glob -type file -types f * .*] {
puts $name
file stat $name temp
parray temp
}
# Get a list of the attributes for the files
foreach name [glob -type file -types f * .*] {
puts $name
puts [file attributes $name]
}
There is more, of course, but these little snippets usually
get me what I need. I suspect you can do similar stuff from a perl
shell,
Clif
--
.... Clif Flynt ... http://www.cflynt.com ... clif at cflynt.com ...
.. Tcl/Tk: A Developer's Guide (2nd edition) - Morgan Kauffman ..
.. 15'th Annual Tcl/Tk Conference: Oct 2008, Philadelphia, PA..
............. http://www.tcl.tk/community/tcl2008/ ............
More information about the Novalug
mailing list