Use readdir() to read the dir file so it doesn't have to stat()
everything. Depending on the tool you use depends on what it does under
the hood. Both ls and find stat() files I believe.
Example:
# time ls -l /dir/with/40k/files | wc -l
6709
real0m2.606s
user0m0.096s
sys 0m0.136s
I suspect you are going to find this task to be extremely difficult, if it's
possible at all on the hardware you have.
There are two sources of the slowness:
1) You have to read the directory file, with 1M files, that's probably on the
order of 200+M of data to actually read from disk.
2) ls is
After a long battle with technology, kitepi...@kitepilot.com wrote:
> ls -f doesn't sort. Still takes longer than find. beats me...
And the short C program I posted earlier? That should actually be faster than
find, though the increased speed may be difficult to see. Thing is, if you're
runnin
ls -f doesn't sort.
Still takes longer than find.
beats me...
ET
R P Herrold writes:
On Fri, 2 Jul 2010, Matt Graham wrote:
That's a bit strange. I'd think "ls -1U --color=never" would spit
everything
out almost as fast as possible, considering.
nope: 'ls' sorts
-- Russ herrold
--
From: R P Herrold
> On Fri, 2 Jul 2010, Matt Graham wrote:
>> I'd think "ls -1U --color=never" would spit everything
>> out almost as fast as possible, considering.
> nope: 'ls' sorts
"man ls" and look up the -U option. (This is not in *BSD ls; there you'd use
-f, which has other side effects in
On Fri, 2 Jul 2010, Matt Graham wrote:
That's a bit strange. I'd think "ls -1U --color=never" would spit everything
out almost as fast as possible, considering.
nope: 'ls' sorts
-- Russ herrold
---
PLUG-discuss mailing list - PLUG-discuss@lists
In theory you could do it like this:
- Establish the count of the files in the directory before you start
whatever daemon is creating/deleting files
- then do something like this:
inotifywait -e delete,create -m /the/dir/to/monitor
(the command is in the inotify-tools package on ubuntu)
- Then
find and wc should work too.
Eric
On Fri, Jul 2, 2010 at 8:02 AM, Matt Graham wrote:
> From: "kitepi...@kitepilot.com"
> > I'll keep it easy: It is a directory that only contains files.
> > So, you'd say: what's wrong with "ls|wc -l" ?
> > There are almost a million files in that directory.
> >
From: "kitepi...@kitepilot.com"
> I'll keep it easy: It is a directory that only contains files.
> So, you'd say: what's wrong with "ls|wc -l" ?
> There are almost a million files in that directory.
> This count has to be placed in a loop in a shell script to report a
> second-to-second delta.
NAHW, that's easy:
ls|wc -l
Or I could, (couldn't I)
find . -type f|wc -l
There are other tricks, like:
du -a|wc -l
Etc, etc, etc...
There are also implications of depth, whether I want only files, and on, and
on, and on...
I'll keep it easy:
It is a directory that only contains file
10 matches
Mail list logo