View Single Post
Old 08-07-2020, 12:20 AM   #60
haertig
Wizard
haertig ought to be getting tired of karma fortunes by now.haertig ought to be getting tired of karma fortunes by now.haertig ought to be getting tired of karma fortunes by now.haertig ought to be getting tired of karma fortunes by now.haertig ought to be getting tired of karma fortunes by now.haertig ought to be getting tired of karma fortunes by now.haertig ought to be getting tired of karma fortunes by now.haertig ought to be getting tired of karma fortunes by now.haertig ought to be getting tired of karma fortunes by now.haertig ought to be getting tired of karma fortunes by now.haertig ought to be getting tired of karma fortunes by now.
 
Posts: 1,921
Karma: 33156336
Join Date: Sep 2017
Device: PW3, Galaxy Tab A9+, Moto G7
Your awk script is bad. Actually, the awk commands are OK, but where you are failing is in trying to make things "neat" using numfmt. Delete that junk that attempts to beautify the output, just display the raw numbers, and your script works much better:

Code:
find -type f -name \*\.\* -printf '%f\0%s\n' | gawk '
  BEGIN {
    FS = "\0";
  }
  {
    split($1, a, ".");
    ext = tolower(a[length(a)]);
    files[ext] += 1;
    size[ext] += $2;
  }
  END {
    PROCINFO["sorted_in"] = "@ind_str_asc";
    for (ext in files) {
      print "*." ext " " files[ext] " files, " size[ext] " bytes";
    }
  }'
haertig is offline   Reply With Quote