Count occurrences of a word in string: Difference between revisions
Jump to navigation
Jump to search
m
→BASH
(→BASH) |
m (→BASH) |
||
| Line 67: | Line 67: | ||
=== Output format I: occurrence & keyword === | === Output format I: occurrence & keyword === | ||
{{exclaim}} The term each line was allowed contains whitespaces. | {{exclaim}} The term each line in the input file was allowed contains whitespaces. | ||
Result of the execution of command: {{kbd | key=<nowiki>sort test.txt | uniq -ic | sort -nr</nowiki>}} {{exclaim}} case insensitive | Result of the execution of command: {{kbd | key=<nowiki>sort test.txt | uniq -ic | sort -nr</nowiki>}} {{exclaim}} case insensitive | ||
| Line 90: | Line 90: | ||
=== Output format II: keyword & occurrence === | === Output format II: keyword & occurrence === | ||
{{exclaim}} The term each line should '''not''' contains whitespaces. | {{exclaim}} The term each line in the input file should '''not''' contains whitespaces. | ||
Result of the execution of command: {{kbd | key=<nowiki>sort test.txt | uniq -ic | sort -nr | awk ' { t = $1; $1 = $2; $2 = t; print; } '</nowiki>}} <ref>[https://stackoverflow.com/questions/11967776/swap-two-columns-awk-sed-python-perl Swap two columns - awk, sed, python, perl - Stack Overflow]</ref>{{exclaim}} case insensitive | Result of the execution of command: {{kbd | key=<nowiki>sort test.txt | uniq -ic | sort -nr | awk ' { t = $1; $1 = $2; $2 = t; print; } '</nowiki>}} <ref>[https://stackoverflow.com/questions/11967776/swap-two-columns-awk-sed-python-perl Swap two columns - awk, sed, python, perl - Stack Overflow]</ref>{{exclaim}} case insensitive | ||