nmh-workers
[Top] [All Lists]

Re: [nmh-workers] for me a useful script

2019-05-23 13:21:35
On Thu, 23 May 2019 13:45:02 -0400, Jude DaShiell said:

echo "first available message:"
scan -width 6|head -1

scan -width 6 first     will be much faster.

echo "last available message:"
scan -width 6|tail -1

scan -width 6 last  will be much faster.

If you have 10,000 entries in a folder, scan first/last still has to read and
sort the directory, but it can find first and last without opening a file.

A quick test:

[~] strace -f scan -width 6 +inbox 2>| /tmp/inbox | head -1
     1
[~] grep open /tmp/inbox | tail -1
openat(AT_FDCWD, "1171", O_RDONLY)      = 3

Yes, it reads that many files before the back-pressure SIGPIPE from 'head -1'
exiting catches up with it.

scan | tail will have to open and read all 10,000 files.....

Attachment: pgpYKsJR_n8a5.pgp
Description: PGP signature

-- 
nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers
<Prev in Thread] Current Thread [Next in Thread>