X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=scripts%2Ffiles%2Fsumming_dir.pl;h=5cd9fa6b9b1f27b80b6401d02f38382f3fd30995;hb=b1627bdc21ecdf68670a339e6461107bb99e4775;hp=43215cca5bab91f60a253cfc64473ba4da77916a;hpb=8c5cfa3cc29ea1ad1d27c3d8db8b32b38cf37d51;p=feisty_meow.git diff --git a/scripts/files/summing_dir.pl b/scripts/files/summing_dir.pl index 43215cca..5cd9fa6b 100644 --- a/scripts/files/summing_dir.pl +++ b/scripts/files/summing_dir.pl @@ -20,7 +20,7 @@ require "filename_helper.pl"; -use Env qw($TMP $color_add $TERM); +use Env qw($TMP $color_add $ls_dot_add $TERM); local($chewed_line) = ""; local(@arg_list); @@ -37,35 +37,33 @@ if ($#ARGV < 0) { @arg_list = &glob_list(@ARGV); } +# add parameters to our chewed_line, but skip items if they are flags we don't +# implement. foreach $dir (@arg_list) { - if ($dir == "-al") { next; } # skip ls directives. - if ($dir == "-l") { next; } # skip ls directives. +#hmmm: fix this by using a pattern, to exclude cmd line parms, but recognize some of them, like recursive? hmmm. + if ($dir eq "-al") { next; } # skip ls directives. + if ($dir eq "-l") { next; } # skip ls directives. $chewed_line = $chewed_line . " \"$dir\""; } if ("$chewed_line" eq "") { -# print "No files matched that path specification.\n"; -# exit 0; - $chewed_line = "." + print "No files matched that path specification.\n"; + exit 0; } # show the header, now that we know there's something to print. print "[" . $print_list . "]\n\n"; -##print "chewed_line is: $chewed_line\n"; - local($temp_file)=`mktemp "$TMP/zz_frdsumdir.XXXXXX"`; chop($temp_file); # drop the main payload, the list of directory info, but also save that # info to a file for analysis. -system("ls -HhlF $color_add $chewed_line"); -system("ls -HhlF $color_add $chewed_line > $temp_file"); +system("ls -HhlF $ls_dot_add $color_add $chewed_line"); +system("ls -HhlF $ls_dot_add $color_add $chewed_line > $temp_file"); # the color_add variable, if defined, will have flags for setting the # directory listing color scheme. -##print "file is: $temp_file\n"; - local($lengths) = 0; # open the file and process the lines to get file lengths. @@ -75,7 +73,6 @@ $pattern="^[^ ]+ +[^ ]+ +[^ ]+ +[^ ]+ +([0-9.]+[KMG]?).*\$"; foreach $file_line () { if ($file_line =~ /$pattern/) { (local $munged = $file_line) =~ s/$pattern/\1/; - #print "munge=$munged\n"; if ($munged =~ /K$/) { chop $munged; $munged *= 1024.0; @@ -97,14 +94,22 @@ foreach $file_line () { close(DIRLIST); unlink($temp_file); # clean up. -#print "lens are: $lengths\n"; - local($total)=int($lengths); local($kbytes)=int($total / 102.4) / 10; local($mbytes)=int($kbytes / 102.4) / 10; +local($gbytes)=int($mbytes / 102.4) / 10; print "\n"; -print "These files occupy $total bytes ($kbytes KB / $mbytes MB).\n"; +# print a fancy listing showing bytes at least, but only showing mb and gb if appropriate. +print "These files occupy $total bytes ($kbytes KB"; +if ($mbytes ne 0) { + print " / $mbytes MB"; +} +if ($gbytes ne 0) { + print " / $gbytes GB"; +} +print ").\n"; + print "Overall Drive Usage (megs):\n"; system("df -m $chewed_line >$temp_file");