实例
1.9 * 9 乘法表,for列表循环,for循环(c语言风格), while循环
可选单层循环
2.使用for循环创建30个用户: test01~test30, 并设置密码为test01123456~test30123456
3.使用循环去判断网段内的IP(1~254),本机除外,可以ping通的使用 ssh远程登录
4.使用$@和$*作为for循环后的列表,并体现出区别
5.使用循环去读取文件内容并输出: 3中方式(1.exec+while循环 2.管道符+while循环 3.重定向+while)
9 * 9 乘法表,for列表循环,for循环(c语言风格), while循环
for列表循环版,如下:
#!/bin/bash
#########################
#File name:9*9.sh
#Version:v1.0
#Email:admin@test.com
#Created time:2022-08-19 19:35:13
#Description:
#########################
for a in {1..9}
do
for b in {1..9}
do
let data=$a'*'$b
if [ $a -eq $b ]
then echo -e "$a * $b = $data\n"
elif [ $a -gt $b ]
then echo -n "$a * $b = $data "
fi
done