Bash: Dice (1-6 random numbers): Difference between revisions
From WikiMLT
m Spas moved page Bash Dice to Bash: Dice (1-6 random numbers) without leaving a redirect |
mNo edit summary |
||
Line 1: | Line 1: | ||
<noinclude | <noinclude>{{ContentArticleHeader/Linux_Server}}</noinclude> | ||
Here is a CLI sample for dice simulation and partial analyze.<syntaxhighlight lang=" | Here is a CLI sample for dice simulation and partial analyze.<syntaxhighlight lang="shell" line="1"> | ||
for i in {1..600}; do shuf -i 1-6 -n 1; done | sort | uniq -c | sort -nr | for i in {1..600}; do shuf -i 1-6 -n 1; done | sort | uniq -c | sort -nr | ||
</syntaxhighlight><syntaxhighlight lang="bash"> | </syntaxhighlight><syntaxhighlight lang="bash"> | ||
117 5 | |||
111 2 | |||
103 3 | |||
91 6 | |||
89 4 | |||
89 1 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
References: | References: | ||
* [https://stackoverflow.com/a/2556282/6543935 Random number from a range in a Bash Script] | * [https://stackoverflow.com/a/2556282/6543935 Random number from a range in a Bash Script] | ||
* [https://stackoverflow.com/a/4923146/6543935 Getting the count of unique values in a column in bash] | * [https://stackoverflow.com/a/4923146/6543935 Getting the count of unique values in a column in bash] |
Revision as of 11:11, 3 August 2022
Here is a CLI sample for dice simulation and partial analyze.
for i in {1..600}; do shuf -i 1-6 -n 1; done | sort | uniq -c | sort -nr
117 5
111 2
103 3
91 6
89 4
89 1
References:
- Random number from a range in a Bash Script
- Getting the count of unique values in a column in bash