← All Exercises

Associative Array Counting

intermediatebash~15min

Background

Associative arrays in bash 4+ enable key-value data structures for counting and grouping.

Problem

Count word frequencies in a file using bash associative arrays.

Input

A text file

Output

Word frequency counts

Sample tests

Sample 1

Input: words.txt
Expected: word counts

Your solution

Learning objective

Learn bash data structures and text processing