Current dir:
$ l
total 12
-rwxr-xr-x 1 broom broom 162 2010-03-26 19:55 add_file_size.pl
-rwxr-xr-x 1 broom broom 608 2010-03-26 19:55 make_self_contained.pl
-rwxr-xr-x 1 broom broom 657 2010-03-26 19:55 maketests.pl
Execute it:
$ find . -print | ./add_file_size.pl
Total: 1427
Figure what the sizes should be:
$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
162+608+657
1427
It matches.
The script file contains the following:
$ cat add_file_size.pl
#!/usr/bin/perl -w
#
use strict;
my $size = 0;
while(<>){
chomp;
next unless (-f $_);
my $file_size = -s $_;
$size += $file_size;
}
print "Total: $size\n";