Подсчет вхождений слов в файле

28 Nov 2013

```shell; gutter: true; first-line: 1; highlight: [] #!/bin/bash if [-f $1] then for word in $(grep -o -i -E ‘(^|b)S(b|$)’ $1|sort -u -f | grep -o -i -E ‘w’ | sort -u -f) do word_stat=$(grep -o -i -E “(^|\W)$word($|\W)” $1 |wc -l) echo ““$word” $word_stat” done; fi;


```shell; gutter: true; first-line: 1; highlight: []
$ ./wordstat.sh text.txt "a" 2578 "a2" 1 "Aaaugh" 2 "abandon" 2 "abandoned" 5 "abandonment" 1 "Aber" 2 "abilities" 1 "ability" 7 "able" 5 <cut>

Теги: консоль обработка текста

Категории: HowTo