Last active
April 23, 2017 00:10
-
-
Save skuenzli/62b3e63bafb8b99d6d0a288065aceaab to your computer and use it in GitHub Desktop.
A script to help pick the planks for the Giles baby room
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 | |
| num_planks=${1:-1} #set default number of planks to pick to 1, specify whatever number you like as argument | |
| declare -a colors=('white' 'natural' 'blue' 'red' 'gray' 'brown') | |
| function pick_color(){ | |
| local color_idx=$(expr $RANDOM % ${#colors[@]}) | |
| echo "${colors[$color_idx]}" | |
| } | |
| for i in `seq 1 ${num_planks}` | |
| do | |
| color=$(pick_color) | |
| echo "${color}" | |
| done; |
Author
skuenzli
commented
Apr 22, 2017
Author
note, this script will not produce perfectly-uniform results, but is probably good enough for a baby room:
kermit:tmp skuenzli$ ./plank-picker.sh 6000 | sort | uniq -c | sort -nr
1041 white
1003 brown
1002 natural
990 blue
988 red
976 gray
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment