Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
list=(these are some words)
|
||||
printf '%s\n' "${list[RANDOM%${#list[@]}]}"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
list=(these are some words)
|
||||
printf '%s\n' "$list[RANDOM%$#list+1]"
|
||||
12
Task/Pick-random-element/UNIX-Shell/pick-random-element.sh
Normal file
12
Task/Pick-random-element/UNIX-Shell/pick-random-element.sh
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# borrowed from github.com/search?q=bashnative
|
||||
|
||||
rand() {
|
||||
printf $(( $1 * RANDOM / 32767 ))
|
||||
}
|
||||
rand_element () {
|
||||
local -a th=("$@")
|
||||
unset th[0]
|
||||
printf $'%s\n' "${th[$(($(rand "${#th[*]}")+1))]}"
|
||||
}
|
||||
|
||||
echo "You feel like a $(rand_element pig donkey unicorn eagle) today"
|
||||
Loading…
Add table
Add a link
Reference in a new issue