Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

counting in awk

Tags:

awk

#!/bin/sh
find ${*-.} -type f -print | xargs file | 
awk '{
$1=NULL;
t[$0]++;
}
end {
for (i in t) printf("%d\t%s\n", t[i], i);
}' | sort -nr

The first "find" line works. But the awk part does not work. I expect the count of file types sorted in descending order.

like image 453
shantanuo Avatar asked Jul 01 '26 05:07

shantanuo


1 Answers

Use END, not end.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!