Print 99 multiplication table: #!/bin/bashfor num in ' seq 9 ' does for NUM1 in ' seq 9 ' do if [$num-ge $num 1]; Then if ((($num * $num 1) >9) then Echo-ne "${num}x${num1}=$ (($num * $num 1) \ t \" Else Ech O-ne "${num}x${num2}=$ (($num * $num 1) \ t" fi fi Doneecho-ne "\ n" Done
Enterprise advanced practical case for the FOR Loop statement:
The command to create a database without logging in to MySQL is mysql-uroot-p***-S, data/mysql.sock-e "create db dbname";
Simulate a production environment, create a library, and then perform a sub-library backup.
#!/bin/bashexport lang= "ZH_CN. UTF-8 "Path=/usr/local/mysql/bin: $PATH #user=root#passwd=123456backup=/tmp/backupsock=/var/lib/mysql/mysql.sock# Comm= "MYSQL-UROOT-E" CREATE Database $dbname "" [!-D $backup] && mkdir $backupfor dbname in a B CDO echo "created Dbname$dbname "Mysql-uroot-s $sock-E" CREATE Database $dbname "echo" Start Backup $dbname "Mysqldump-uroot-s $sock $d bname | Gzip >> $backup/"$dbname" _$ (date +%f). Sql.gzdone
Using the shell to write 99 multiplication tables, MySQL sub-Library backup