leet-code/word-frequency/sol.sh

4 lines
155 B
Bash

#!/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