String test:
= =: Test for equality, equality is true, not equal to False
! =: Tests are not equal, unequal to true, equal to False
>
<
-N String: Tests whether the specified string is empty, empty is true, not empty is false
-S string: Tests whether the specified string is not empty, is not empty, and empty is false
BC Command usage
For example: echo "SCALE=2;111/22;" | BC reserved two-bit accuracy
Loop control
For
While
Until
for variable in list; Do
Loop body
Done
Generating a list of integers
1. {1..100}
2, ' SEQ [number of start] [step] End number
For example: SEQ 1 2 10 generates cardinality from 1 to 10
Script instance: Generate 10 random numbers and find the maximum and minimum values
#!/usr/bin/ksh
Declare-i max=0
Declare-i min=0
For num in {1..10}
Do
Myrandom= $RANDOM
If [$num-eq 1]; Then
min= $myRandom
Fi
If [$num-lt 10]
Then
Echo-n "$myRandom,"
Else
echo "$myRandom"
Fi
[[$myRandom-gt $max]] && max= $myRandom
[[$myRandom-lt $min]] && min= $myRandom
Done
echo "Max= $max"
echo "Min= $min"
Case statement:
Case variable in
value1)
statement;;
Values
statement;;
*)
statement;;
Esac
This article is from the "Forget the Past" blog, please be sure to keep this source http://xujingbo.blog.51cto.com/4633099/1828219
Shell Programming Details (iii)