One, 99 multiplication table
# !/usr/bin/env Bash Test () {for ((i=1;i<10;i++)) does for ((x=1;x<= $i; x + +)) do " $x x $i = $ (($i * $x)) " Done "\ n"' begin{rs= ""}{print }'
[Email protected] ~/bash_script/2016-08-16 $ bash 99.sh 1 x 1 = x 2 = x 2 = x 3 = x 3 = x 3 = x 4 = x 4 = 4 = 124 x 4 = 161 x 5 = x 5 = 103 x 5 = 154 x 5 = 205 x 5 = 251 x 6 = x 6 = 123 x 6 = 184 x 6 = 245 x 6 = 306 x 6 = 361 x 7 = x 7 = 143 x 7 = 214 x 7 = 285 x 7 = 356 x 7 = 427 x 7 = 491 x 8 = x 8 = 163 x 8 = 244 x 8 = 325 x 8 = 406 x 8 = 487 x 8 = 568 x 8 = 641 x 9 = x 9 = 183 x 9 = 274 x 9 = 365 x 9 = 456 x 9 = 547 x 9 = 638 x 9 = 729 x 9 = 81
Second, to display chess 8*8 chessboard
#!/bin/bashLine_0 () { forIinch{0..47}doif[[$ (($ ($i/8)% 2)) = ="0"] then echo-ne"\033[41m \033[00m" ElseEcho-ne"\033[46m \033[00m"fidone}line_1 () { forIinch{0..47} doif[[$ (($ (($i/8))% 2))! ="0"] then echo-ne"\033[41m \033[00m" ElseEcho-ne"\033[46m \033[00m"fi done}chess () { forXinch{0..23}doif[[$ (($ (($x/4))% 2))! ="0"] then Line_0Elseline_1 fi echo-E"\ n"done}chess| Gawk'begin{rs= ""}{print}'International Chess
#!/usr/bin/bashN=1Test () { forXinch{1..8} doif[[$ ($x% 2) = = ="0"] then echo-E"\033[41m \033[00m" ElseEcho-E"\033[46m \033[00m"fi Done} while[[$n < 9]]doif[[$ ($n% 2) = = ="0"] Then test>$n. txtElseTest| TAC >$n. txt Filet n+=1Donepaste {1..8}.txt >Result.txtcat Result.txt| Sed's/\t//g'RM Result.txt {1..8}.txttac:international Chess
Three, take 10 random number of the maximum and minimum value
#!/usr/bin/env Bashmax=$RANDOMmin=$maxecho $max for((i=9;i>0;i--)) do Max_old=$max Max=$RANDOM Echo $maxif[[$max-lt $max _old]] Then Min_old=$min min=$maxif[[$min-GT $min _old]] Then min=$min _old fi Max=$max _old Fidoneecho-E"\nlargest: $max; smallest: $min"
[Email protected] ~/bash_script/-$bash max_min .sh5677 282522733313922371922836241261023560 12516 282522412
Max and Min
Iv. sum of 1-100 integers
#!/usr/bin/"" nsumn=0for ((i=1; i<= $N; i++))do sumn=$ (($sumN + $i))didecho" $sumN"
Linux Basic Notes--[008]--08 month 16th class Exercise {Bash script}