Учитывая Ввод , используйте cut
, sort
, uniq
иsed
:
cut -d ' ' -f1,3 Input |
sort | uniq -c |
sed 's/^ *//;s/^\([0-9]*\) \([^ ]*\)/\2 \1/'
Использование datamash
иsed
:
datamash -t ' ' -g1,3 -s countunique 2 < Input |
sed 's/\(.*\) \(.*\) \(.*\)/\1 \3 \2/'
Выход одного из:
A 1 -05:00
A 2 -06:00
A 1 -07:00
B 2 -05:00
C 1 -05:00
C 3 -06:00