Quote:
Originally Posted by haertig
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";
}
}'
|
thanks haertig for correcting the code. It was originally created by someone else. Unfortunately, because I don't code, I didn't know how to read the code.
I now ran your corrected code and got this result:
Quote:
*.azw 6 files, 34806823 bytes
*.azw3 178 files, 2569168678 bytes
*.azw4 3 files, 238715160 bytes
*.cbz 6 files, 1766121940 bytes
*.chm 1 files, 904553 bytes
*.db 1 files, 24219648 bytes
*.djvu 17 files, 70510310 bytes
*.epub 6839 files, 39640384895 bytes
*.htmlz 113 files, 491346536 bytes
*.jpg 7812 files, 2121182039 bytes
*.json 1 files, 30310 bytes
*.kepub 3 files, 2326374 bytes
*.kfx 1 files, 2052924 bytes
*.kfx-zip 7 files, 27629860 bytes
*.mbp 12 files, 1440 bytes
*.mobi 214 files, 365347885 bytes
*.odt 1 files, 31448 bytes
*.opf 3431 files, 40932854 bytes
*.original_epub 193 files, 1543362814 bytes
*.pdf 768 files, 7765519460 bytes
*.txt 1 files, 381732 bytes
*.zip 2 files, 1282446 bytes
|
I've attached a screenshot of filetypes in the Calibre program.
Update: The numbers (of files per type) is a match!