我的當前目錄中有 3 個檔案,我需要找到總體上最常用的詞。我怎么做?我只能從每個檔案中找到最常用的單詞:
$ for file in *; do
printf '%s : %s\n' "$(grep -Eo '[[:alnum:]] ' "$file" | sort | uniq -c |
sort -rn | head -n1)" "$file"
done
uj5u.com熱心網友回復:
將所有檔案連接到一個流中并使用相同的管道:
cat * | grep -Eo '[[:alnum:]] ' | sort | uniq -c | sort -rn | sed 1q
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/512516.html
