NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

How high can wc go?



The other day on a NetBSD/i386 5.0.2 machine I made a 1833 GiB file consisting of 30752636928 64-character lines (including the new line char). Later I ran wc on it, expecting its output to be incorrect as a result of overflows in the variables it uses, but the answers were right:

% ls -l /mnt2
total 3845018400
-rw-r--r--  1 root  wheel  1968168763392 Jun 14 08:28 1833GiB.txt
% /usr/bin/time wc /mnt/1833GiB.txt
 30752636928 30752636928 1968168763392 /mnt2/1833GiB.txt
   125997.76 real    121238.03 user      3731.70 sys
%
% dc
4k
1833 2 30^ * 64 /p
30752636928.0000

30752636928 64 * p
1968168763392
q
%

I was wondering if anyone knows how many lines, words, and characters wc can keep track of? It seems that it uses some kind of tricky technique like dc to avoid overflows occurring?


Ray


Home | Main Index | Thread Index | Old Index