A classmate on the group asked to calculate 1 to 100000 of the number of occurrences of 93, and then I wrote the script.
Cat count.sh #!/bin/bashsum=0for num in {1..100000}doecho $num | grep 93[$?-eq 0] && ((sum=sum+1)) Doneecho "sum= $sum"
Then one of the students gave me the answer, and the second killed me 10,000 miles.
Seq 1 100000 | grep |wc-l
I want to quiet/(ㄒoㄒ)/~~ let me quietly 650) this.width=650; src= "/e/u261/themes/default/images/spacer.gif" style= "Background:url ("/e/ U261/lang/zh-cn/images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "spacer.gif"/> 650) this.width=650, "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/images /localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>
This article is from the "Do not forget Beginner's mind" blog, please be sure to keep this source http://winterysea.blog.51cto.com/9677346/1663578
Calculate the number of occurrences of 93 in 1 to 100000