#!/bin/bash for i in 1,3,4,6 ##有几个数就循环几次 do echo $i done for m in $( cat /root/num.log) ## /root/num.log有几行就循环几次 do echo -e "$m \n" ##echo -e 才能识别“\n” done
read -p "please input default name: " name read -p "please input num of users: " num if [ ! -z "$name" -a ! -z "$num" ] ###需要注意的是!和 -z中间必须有空格 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 fi fi
时间: 2024-09-25 02:28:12