leet-code/word-frequency/sol.sh

4 lines
155 B
Bash
Raw Permalink Normal View History

2021-11-08 20:28:06 +00:00
#!/bin/sh
grep -oE "[a-z]+" words.txt | sort -u | xargs -I{} sh -c 'echo {} $(grep -oP "(?<![a-z]){}(?![a-z])" words.txt | wc -w)' | sort -nr -t " " -k 2