"Shell" for loop

Source: Internet
Author: User

#!/bin/bashfor i in 1,3,4,6 # #有几个数就循环几次                does echo $i        donefor m in $ (cat/root/num.log)  # #/root/num.log a few lines Just loop a few times do                echo-e "$m \ n"  # #echo-E to recognize "\ n"        done       

 

Read-p "Please input the default name:" NAMEREAD-P "please input num of users:" NUMIF [! -Z "$name"-A! -Z "$num"]  # # #需要注意的是! And-Z must have a space then                y=$ (echo $num |sed ' s/[0-9]//g ')  # #判断是否为纯整数                if [-Z $y] then for                                ((i=1; i<= $num; i=i+1))                                        do                                                echo "Add user $name _$i"                                        done                Fifi

  

"Shell" for loop

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.