Unix script to find the total size of files

Create a shell script file and copy paste the code. Please let me know if you find any bugs
awk '
# filesum: list files and total size in bytes
# input: long listing produced by "ls -l"
BEGIN {
printf("%15s %s\n", "BYTES", "FILE");
}
# test for 9 fields, files begin with "-"
NF == 9 && /^-/ {
++filenum;            # count files
sum += $5;            # accumulate sizes
num = sprintf("%.2f", $5);
while (num ~ /[0-9][0-9][0-9][0-9]/) {
sub(/[0-9][0-9][0-9][,.]/, ",&", num);
}
sub(/\..*/, "", num);
printf("%15s %s\n", num, $9);    # print size and name
}
END {
num = sprintf("%.2f", sum);
while (num ~ /[0-9][0-9][0-9][0-9]/) {
sub(/[0-9][0-9][0-9][,.]/, ",&", num);
}
sub(/\..*/, "", num);
printf("\n%15s total bytes in %d files\n\n", num, filenum);
}'
FacebookTwitterGoogle+Share