Take out the
-l from the
wc command and you get byte (and word) counts for each file as well. (Why did you add it in the first place?) Some simple post-processing to divide by 1,000 or 1,024 and increasing the unit is easy to add to the awk script. (Do you want MB or MiB, i.e. 1000 or 1024? See
http://en.wikipedia.org/wiki/Mebibyte)
Code:
wc /data/XYZ/Daily_File*.txt |
nawk -v OFS=, '{ bytes=$3; suff="KMGT"; i=0;
while (bytes > 1000) { bytes = int(bytes/1000); i++ }
print $4, $1, bytes (i > 0 ? (" " substr(suff,i,1) "B") : " bytes") }'
For 1024-byte units,
bytes >>= 10 is probably more efficient than
bytes = int(bytes/1024)
As an engineering recommendation, I would still suggest that you put the raw numbers in the CSV file, and leave the arrangement of the presentation as KiB or whatever to the consumer of that file.