Shell script output Sort and count number of occurrence of lines

iKnow-IT banner

If you have a command that you will count the unique occurrences in lines.
e.q. you have a command that shows a system list and a version number 
and you are interested in how many of each version in this list

$ tacmd listsystems

host1:08               08           01.20.00.00 Y
host2:08               08           03.20.00.00 Y
host3:08               08           01.20.00.00 Y
host4:08               08           03.20.00.00 Y
host5:08               08           01.20.00.00 Y
host6:08               08           03.22.00.00 Y

You can sort and count the number of occurrence of the lines 

$ tacmd listsystems | awk '{print $3}' | sort | uniq -c

   3 01.20.00.00
   2 03.20.00.00
   1 03.22.00.00

the command

$ tacmd listsystems | awk '{print $3}'

gives the result 

01.20.00.00
03.20.00.00
01.20.00.00
03.20.00.00
01.20.00.00
03.22.00.00

The trick is 

 <command> | sort | uniq -c

sort the order and then count the unique values