Using hash table to count specific strings, and out put a result with time it repeat.
File A
AAA
BBB
CCC
DDD
BBB
DDD
AAA
CCC
BBB
AAA
BBB
CCC
BBB
Result
AAA 3
BBB 5
CCC 3
DDD 2
Using hash table to count specific strings, and out put a result with time it repeat. File A
Result
|
|||
|
Is this homework? If not, just use
If you need to script it yourself for some reason, you could use Perl:
If you really need to use a shell script, you could do (here
|
|||||||||||||
|
With awk:
where |
|||||
|
Another possibility is
|
|||||||||||||
|