开发者

counting in awk

开发者 https://www.devze.com 2022-12-16 13:47 出处:网络
#!/bin/sh find $开发者_如何学Go{*-.} -type f -print | xargs file | awk \'{ $1=NULL; t[$0]++; } end {
#!/bin/sh
find $开发者_如何学Go{*-.} -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.


awk is case sensitive - "end" should be "END"


Use END, not end.


Try to add a blank between the tick and the {:

awk ' {

Some versions of AWK need this.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号