标签:print code printf 个数 span ash 编写 字符 shell脚本练习
#! /bin/bash sum=0 for i in `seq 1 100`;do sum=$[$i+$sum] done echo $sum
要求:如果输入的数字小于1,则重新输入,直到输入正确的数字为止。
#! /bin/bash n=0 while [$n -lt "1"];do read -p "Please input a number:"n done sum=0 for i in `seq 1 $n`;do sum=$[$i+$sum] done echo $sum
要求:所有用户同属于users组。
#! /bin/bash groupadd users for i in `seq -w 0 99`;do uesradd -g users user_0$i4 done
#! /bin/bash for((i=1;i<20;i++)); do if(i<10);then jsj="jsj0$i"; else jsj="jsj$i"; fi useradd $jsj done
#! /bin/bash echo -n your choice: read choice case $choice in [g,G] echo "She is a girl." ;; [b,B] ehco "He is a boy." ;; *) echo "I don‘t know." ;; esac
#! /bin/bash read -p "imput num1:"a read -p "input num2:"b read -p "input operator:"o case $o in +)let "res=a+b" echo $res;; -)let "res=a-b" echo $res;; /)awk‘BEGIN{printf %.2f\n",‘$a‘/‘$b‘}‘;; *)let "res=a*b" echo $res;; esac
标签:print code printf 个数 span ash 编写 字符 shell脚本练习
原文地址:https://www.cnblogs.com/OctoptusLian/p/8979646.html