Linux class Assignment Wednesday, if there is a poor consideration to the place, also please advise.
Shell Processing Text See this blog for common commands related to
#
#如果输入两个参数 is the first to count the number of words, the second is the article to be counted
#如果输入一个参数 the default count of words is 10
#
Specific ideas:
Replacing various symbols with newline (tr command)
Uppercase to lowercase (tr command)
Sort, count the number of words and remove duplicates (sort and uniq)
Sort by the high and low number of occurrences (sort)
Print n A word that needs to be counted
#!/bin/bashif [$#-ne 2-a $#-ne 1]; then echo "Usage: ' basename $ ' [n] Input file" echo exitfiif [$#- EQ 1];then i_top=10 i_file=$1fiif [$#-eq 2];then i_top=$1 i_file=$2fitr-sc "[A-z][a-z]" " [\012 *] " < $I _file | TR "[A-z]" "[A-z]" | sort | uniq-c | Sort -k1-n-R | head-$I _top | nl