In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Original text: linux system calculation adds the sum of 1 to 100 thought storm
Preface to the blog post:
This blog is "Old Boy linux Employment training Center-the seventh pre-class examination and after-class answers explained in class."
Original title: find 1, 2, 3. 100 through shell programming or command line. And to learn how to use shell and linux commands.
After reading this blog, you will be familiar with the syntax and application of for statements, while statements and until statements in shell programming. In the calculation of linux, you will be familiar with the syntax and application skills of calculation commands such as (), let, expr, bc, and so on. Finally, you will be familiar with the skills of using important commands in linux, such as seq, tr, awk, sed, {1... 100}, and so on!
Special reminder:
The writing of this blog does not lie in how many implementation methods have been used, but to bring friends a learning idea and method for reference, which is what the old boy has been pursuing when giving lectures in the actual combat training class of linux operation and maintenance. An excellent teacher must have a way to really input his knowledge and skills into his students' heads, in addition to the four elements that old boys and students often say to learn operation and maintenance well: goal, method, hard work, and persistence. It is inseparable from an excellent teacher to enlighten students' ideas and to cultivate students' ability to think actively through special interesting classroom teaching. Of course, it is also necessary to cultivate students' ability to learn from others, so that students can learn the operation and maintenance technology they should learn unwittingly in active thinking, so as to develop good learning and thinking habits.
The old boy found that students who are not good at technology are actually not the problem of IQ, but mainly the problem of thinking, thinking and method. Improving students' thinking, thinking, consciousness and thinking is also the core content of linux practical training for old boys.
The purpose of the old boy linux training: to train a limited number of students to become the technical elite of the enterprise!
This is the goal that the old boy insists on disdain to pursue!
That's all the nonsense. Let's get down to business!
Highlights of ideas:
①. C language for loop structure and (()) computational shell script
[oldboy@student ~] $cat for1.sh
#! / bin/sh
Jroom0
For (I change all the newline labels at the end of 1... 100 digits to a plus sign, you get 1 / 2 / 3 / 100 +.
The plus sign at the end of the string expression concatenated by 3.sed 's #\ + $#\ ncarriage return = > is replaced with a newline (carriage return) character.
4.bc = = > give it to bc for calculation
For more detailed information about this method, please see the classroom explanation or comments on the actual combat training of the old boy linux.
⑤. (())
[oldboy@student ~] $cat for4.sh
#! / bin/bash
Sum=0
For ((iTun1)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.