File tree 2 files changed +16
-5
lines changed
functions_scripts/scripting/bash
2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 4
4
</div >
5
5
<br ><br >
6
6
7
- ** Gnu-linux-shell-scripting** is a foundation for shell scripting in the GNU/Linux environment .
7
+ ** Gnu-linux-shell-scripting** is a foundation for shell scripting in GNU/Linux.
8
8
9
9
It is made up of the following four types of solutions:
10
10
@@ -13,9 +13,9 @@ It is made up of the following four types of solutions:
13
13
3 . One-liners
14
14
4 . Aliases
15
15
16
- # Paradigms
16
+ # Categories
17
17
18
- Here is a list of all the paradigms with a few examples in which all solutions exist :
18
+ Here is a list of all the categories with a few examples in each :
19
19
20
20
## Application management
21
21
@@ -75,5 +75,5 @@ Here is a list of all the paradigms with a few examples in which all solutions e
75
75
76
76
# Code style guidelines
77
77
78
- All the solutions in this repository follow [ these ] ( https://github.com/computingfoundation/gnu-linux-shell-scripting/wiki ) standard guidelines .
78
+ All the solutions in this repository follow [ this ] ( https://github.com/computingfoundation/gnu-linux-shell-scripting/wiki ) standard guideline .
79
79
Original file line number Diff line number Diff line change @@ -33,7 +33,18 @@ generateRandomNumber() {
33
33
[ " $# " -ne 2 ] && return 1
34
34
[[ " ${1} " =~ ^[0-9]+$ && " ${2} " =~ ^[0-9]+$ ]] || return 1
35
35
[ " ${1} " -gt " ${2} " ] && return 1
36
- echo $(( ( RANDOM % ( "${2} " - "${1} " + 1 ) + "${1} " )) )
36
+ printf ' %s' $(( ( RANDOM % ( "${2} " - "${1} " + 1 ) + "${1} " )) )
37
+ }
38
+
39
+ # Generate a random decimal between ".00" and ".99".
40
+ # Usage:
41
+ # generateRandomDecimal
42
+ function generateRandomDecimal {
43
+ [ " $# " -ne 2 ] && return 1
44
+ [[ " ${1} " =~ ^[0-9]+\. [0-9]+$ && " ${2} " =~ ^[0-9]+\. [0-9]+$ ]] || return 1
45
+ out=$( bc <<< " scale=2; $(printf '0.%02d' $(( $RANDOM % 100))) / 2" )
46
+ if [ " ${out} " = ' 0' ]; then out=' .00' ; fi
47
+ printf ' %s' " ${out} "
37
48
}
38
49
39
50
You can’t perform that action at this time.
0 commit comments