double-colored-ball.sh
#!/bin/bash
echo "Red Ball:"
awk '{print $1"\n"$2"\n"$3"\n"$4"\n"$5"\n"$6}' /root/double-colored-ball.txt | sort |uniq -c | sort
echo
echo "Blue Ball:"
awk '{print $7}' /root/double-colored-ball.txt | sort | uniq -c | sort
验证:
[root@logstash ~]# cat double-colored-ball.txt
01 04 11 28 31 32 16
04 07 08 18 23 24 02
02 05 06 16 28 29 04
04 19 22 27 30 33 01
05 10 18 19 30 31 03
02 06 11 12 19 29 06
[root@logstash ~]#
[root@logstash ~]# sh double-colored-ball.sh
Red Ball:
1 01
1 07
1 08
1 10
1 12
1 16
1 22
1 23
1 24
1 27
1 32
1 33
2 02
2 05
2 06
2 11
2 18
2 28
2 29
2 30
2 31
3 04
3 19
Blue Ball:
1 01
1 02
1 03
1 04
1 06
1 16
[root@logstash ~]#