Shell command _for

Source: Internet
Author: User



chmod 755 demo.sh./demo.sh
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 6667686970 #!/bin/bash# Author:James 2016-10-15# 集合以空格分割fori in 1 2 3 4 5 6    do        echo "$i"    done


#!/bin/bash# Author:James 2016-10-15# 批量压缩脚本cd /tmp/shs#所有sh文件覆盖到sh.log文件ls *.sh > sh.logfor i in $(cat sh.log)    do        #tar -zxf $i &>/dev/null        echo "File Name is $i"    donerm -rf /tmp/shs/sh.log


#!/bin/bash# Author:James 2016-10-15# 计算1..100之和sum=0for(( i=1;i<=100;i++ ))        do                #echo "$i"                sum=$(( $sum+$i ))        doneecho "sum is:$sum"


#!/bin/bash# Author:James 2016-10-15# 批量添加用户和默认密码 #等待30秒输入nameread -t 30 -p "input name:" nameread -t 30 -p "input password:" passread -t 30 -p "input number:" num# 输入的name,pass,num都不是控制if [ ! -z "$name" -a ! -z "$pass" -a ! -z "$num" ]        then                # 将num变量以数字开头的结尾的字符改为空字符串                y=$(echo $num | sed ‘s/^[0-9]*$‘//g)                #变量y为空,表示num变量都是数字                if [ -z "$y" ]                        then                                for(( i=1;i<=$num;i++ ))                                        do                                                #批量添加用户                                                /usr/sbin/useradd "$name$i" &>/dev/null                                                #批量赋予默认密码                                                echo $pass | /usr/bin/passwd --stdin "&name$i" &>/dev/null                                        done                fifi# 使用cat /etc/passwd 查看用户是否增加成功



From for notes (Wiz)

Shell command _for

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.