Hands-on task
Word frequencies via an associative array
In /root/words.txt there are words (one per line, with repeats). Write /root/count.sh that uses an associative array to count how many times the word error occurs (exactly that word: Error and errors are different words), and outputs the number. Run it, and put the result in /root/errors.txt. The script is easiest to write in the Editor tab above the terminal.
- associative arrays
- declare -A
- while read loop
- bash arithmetic
- frequency counting