Skip to content

Instantly share code, notes, and snippets.

@hSATAC
Created September 15, 2015 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hSATAC/abc169771bf88fac5cb8 to your computer and use it in GitHub Desktop.
Save hSATAC/abc169771bf88fac5cb8 to your computer and use it in GitHub Desktop.
random element
#!/bin/bash
rand() {
echo $(( $1 * RANDOM / 32768 ))
}
rand_element () {
local -a th=("$@")
echo "${th[$( rand ${#th[@]} )]}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment