for i in {1..100}
do
echo "$i"
done
# 范围支持
## 空格 1 2 3 4
## tab 1 2 3
## for i in (cat file.txt)
## for i in seq 100 # 1到一百
## for i in seq 2 100 # 2到一百
## for i in $(seq -w 2 100) # 0 填充
-------------------------------------------------------------------------------
for i in {a..z}
do
echo "$i"
done
-------------------------------------------------------------------------------
# 两个集合破解
for i in {a..z}{1..10}
do
echo "$i"
done
-------------------------------------------------------------------------------
# 上上边的区别在于 这个次数是一个变量
i={次数}
for ((j=0; j<i; j++)); do
执行多少次
done
for i in {1..100}
do
# clear
line="<---------------------------------------------------------------------------------------------------->"
for ((j=0; j<i; j++)); do
line=$(echo "$line" | sed 's/-/=/')
done
echo "$line $i %"
sleep 0.1
# echo "$i"
# echo "Hello, World!"
done
i=0
while [$i -lt 100]
do
a=$[$a+1]
echo "$a"
done
i=0
while [$i -lt 100]
do
let a++
echo "$a"
done
for i in {1..10}
do
if [ $i eq 5 ];then
continue
fi
echo "$i"
done
# continue 跳过本次循环
# break 结束整个循环
# exit 结束程序
for i in $(seq 9)
do
for j in $(seq 9)
do
echo -ne "$i * $j = $(($i * $j))\t"
done
echo ''
done
echo -----------------------------------------------------------------------
# 三角
for i in $(seq 9)
do
for j in $(seq $i)
do
echo -ne "$i * $j = $(($i * $j))\t"
done
echo ''
done
# 创建十个用户 截取uuid 第一段为 密码 把密码保存到一个文件中
# user_01 -- user_10
uname=user_
isPasswd="密码是"
for i in $(seq -w 10)
do
echo $uname$i
useradd $uname$i
myPasswd=$(echo `uuidgen` | awk -F "-" '{print $1}')
echo $myPasswd | passwd --stdin $uname$i
echo $uname$i$isPasswd$myPasswd >> ./myP.txt
# userdel -r $uname$i # 删除用户
done
坚持 是一个很简单的事情 也是一个很困难的事情