使用shell编写九九乘法表,mysql分库备份

前端之家收集整理的这篇文章主要介绍了使用shell编写九九乘法表,mysql分库备份前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
打印99乘法表:
#!/bin/bash
fornumin`seq9`
do
fornum1in`seq9`
do
if[$num-ge$num1];then
if((($num*$num1))>9)
then
echo-ne"${num}x${num1}=$(($num*$num1))\t"
else
echo-ne"${num}x${num2}=$(($num*$num1))\t"
fi
fi
done
echo-ne"\n"

done

for循环语句的企业高级实战案例:

不登陆MysqL创建数据库的命令为MysqL -uroot -p*** -S 、data/MysqL.sock -e "create database dbname";

模拟生产环境,创建库然后进行分库备份。

#!/bin/bash
exportLANG="zh_CN.UTF-8"
PATH=/usr/local/MysqL/bin:$PATH
#user=root
#passwd=123456
backup=/tmp/backup
sock=/var/lib/MysqL/MysqL.sock
#comm="MysqL-uroot-e"createdatabase$dbname""
[!-d$backup]&&mkdir$backup

fordbnameinabc
do
echo"创建dbname$dbname"
MysqL-uroot-S$sock-e"createdatabase$dbname"
echo"开始备份$dbname"
MysqLdump-uroot-S$sock$dbname|gzip>>$backup/"$dbname"_$(date+%F).sql.gz
done
原文链接:https://www.f2er.com/bash/388724.html

猜你在找的Bash相关文章