Jesper Noehr wrote:
> 
> On Mon, 29 Dec 2003 13:19:29 -0800, John W. Krahn <[EMAIL PROTECTED]> wrote:
> >
> > $ ls -l test.txt
> > -rw-r--r--    1 john     users         187 Jul  9 11:54 test.txt
> > $ perl -le'print +(lstat shift)[11]' test.txt
> > 4096
> > $ du -b test.txt
> > 4096    test.txt
> > $ du test.txt
> > 4       test.txt
> Great example, thanks. You have any idea how I can rehack my program to
> return what du does? That is, diskspaceusage.

As you can see from the perl script above, the twelfth field of stat and
lstat is the block size.

$ ls -l file.txt
-rw-r--r--    1 john     users       22982 Nov 13 23:28 file.txt
$ du -b file.txt
24576   file.txt
$ perl -le'$x = shift;
           $b = (lstat $x)[11];
           $s = -s _;
           print "$s  ", $s + ( $b - ( $s % $b ) );
           ' file.txt 
22982  24576



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to