shell脚本

For循环
九九乘法表
#!/bin/bash
for i in {1..9}
do
for j in seq $i
do
echo -e "${j}x${i}=$[i*j]\t\c"
done
echo
done

求奇数和:
#!/bin/bash
sum=0
for i in seq 1 2 100 求偶数和:seq 2 2 100
do
let sum+=i
let i++
done
echo $sum

批量该文件名后缀
#!/bin/bash
for i in {wang.conf,hao.bak,wh.html}
do
j=echo $i|sed -En ‘s/(.*)\.([^.]+)$/\1/gp‘
mv $i $j.txt
done

shell脚本

上一篇:ubuntu 18.04 网络图标不见的问题解决方案


下一篇:shell编程--3