Skip to content

Commit

Permalink
Add some shell
Browse files Browse the repository at this point in the history
  • Loading branch information
beyondyyh committed Nov 22, 2019
1 parent ef3b3e2 commit b5cd246
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
| Type |
|------|
|[Algorithms](./algorithms)|
|[Shell](./shell)|
12 changes: 12 additions & 0 deletions shell/192.wordsCount.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#/bin/bash
awk '{
for(i=1;i<=NF;i++){
res[$i]+=1}
} END {
for(k in res){
print k" "res[k]
}
}' ./testdata/192.txt | sort -nr -k2


# run: sh ./192.wordsCount.sh
4 changes: 4 additions & 0 deletions shell/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Shell
| No. | Title | Src | Difficulty |
|-----| ----- | --- | ---------- |
|0192|[统计词频](https://leetcode-cn.com/problems/word-frequency/)[src](./shell/192.wordsCount.sh)|S|
3 changes: 3 additions & 0 deletions shell/testdata/192.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
the day is sunny the the
the sunny is is
english is the most popular language around the world

0 comments on commit b5cd246

Please sign in to comment.