Created
June 30, 2022 19:21
-
-
Save sevenissimo/e9d38d379a19d300001ee404bae4511a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| #set +x | |
| # Create an array named as param ($1) or 'FOO' | |
| # and fill it with random numbers without naming it | |
| rand() { | |
| declare -n ref="${1:-FOO}" | |
| for i in {1..10}; do | |
| ref[$i]=$RANDOM | |
| done | |
| } | |
| rand arr | |
| echo "arr=${arr[@]}" | |
| rand | |
| echo "FOO=${FOO[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment