Counting in 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 line of search. But the awk part does not work. I expect the number of file types to be sorted in descending order.

+3
source share
3 answers

awk is case sensitive - end must be END

+11
source

Use END, not END.

+2
source

Try adding a space between the tick and {:

awk ' {

Some AWK versions need this.

0
source

Source: https://habr.com/ru/post/1728033/


All Articles