:
$ cat a.cnt b.cnt | awk '{a[$2]+=$1} END{for (i in a) print a[i],i}'
1 a
2 b
3 c
, , , 10 , cat f1 f2 ... awk.
, ( !):
awk '{a[$2]+=$1} END{for (i in a) print a[i],i}' *cnt
, , cnt.
, :
- a, b, c - , ?
- , , ? -
sort | uniq -c -style , ?
:
awk '{count=$1; $1=""; a[$0]+=count} END{for (i in a) print a[i],i}' *cnt
, sort | uniq -c cnt, . - :
awk '{a[$0]++} END{for (i in a) print a[i], i}' file
Example
$ cat a.cnt
1 and some
2 text here
$ cat b.cnt
4 and some
4 and other things
2 text here
9 blabla
$ cat *cnt | awk '{count=$1; $1=""; a[$0]+=count} END{for (i in a) print a[i],i}'
4 text here
9 blabla
4 and some
4 and other things
:
$ cat b
and some
text here
and some
and other things
text here
blabla
$ awk '{a[$0]++} END{for (i in a) print a[i], i}' b
2 and some
2 text here
1 and other things
1 blabla