Bash: Dice (1-6 random numbers): Difference between revisions

From WikiMLT
m (Стадий: 3 [Фаза:Разработване, Статус:Разутвърден]; Категория:Linux Server)
m (Стадий: 6 [Фаза:Утвърждаване, Статус:Утвърден]; Категория:Linux Server)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<noinclude><!--[[Category:Linux_Server|?]]-->{{ContentArticleHeader/Linux_Server}}</noinclude>
<noinclude>{{ContentArticleHeader/Linux_Server}}</noinclude>
Here is a CLI sample for dice simulation and partial analyze.<syntaxhighlight lang="bash">
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">
$ for i in {1..600}; do shuf -i 1-6 -n 1; done | sort | uniq -c | sort -nr
117 5
    117 5
111 2
    111 2
103 3
    103 3
91 6
    91 6
89 4
    89 4
89 1
    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]
Line 20: Line 17:
{{devStage  
{{devStage  
  | Прндл  = Linux Server
  | Прндл  = Linux Server
  | Стадий = 3
  | Стадий = 6
  | Фаза  = Разработване
  | Фаза  = Утвърждаване
  | Статус = Разутвърден
  | Статус = Утвърден
  | ИдтПт  = Spas
  | ИдтПт  = Spas
  | РзбПт  = {{REVISIONUSER}}
  | РзбПт  = Spas
  | АвтПт  = Spas
  | АвтПт  = Spas
  | УтвПт  = Spas
  | УтвПт  = {{REVISIONUSER}}
  | ИдтДт  = 20.07.2022
  | ИдтДт  = 20.07.2022
  | РзбДт  = {{Today}}
  | РзбДт  = 3.08.2022
  | АвтДт  = 20.07.2022
  | АвтДт  = 3.08.2022
  | УтвДт  = 20.07.2022
  | УтвДт  = {{Today}}
  | ИдтРв  = [[Special:Permalink/28954|28954]]
  | ИдтРв  = [[Special:Permalink/28954|28954]]
  | РзбРв  = {{REVISIONID}}
  | РзбРв  = [[Special:Permalink/29849|29849]]
  | АвтРв  =  
  | АвтРв  = [[Special:Permalink/29850|29850]]
  | РзАРв  = [[Special:Permalink/28958|28958]]
  | РзАРв  = [[Special:Permalink/28958|28958]]
  | УтвРв  =  
  | УтвРв  = {{REVISIONID}}
  | РзУРв  = [[Special:Permalink/28960|28960]]
  | РзУРв  = [[Special:Permalink/28960|28960]]
}}
}}
</div>
</div>
</noinclude>
</noinclude>

Latest revision as of 12:12, 3 August 2022

Here is a CLI sam­ple for dice sim­u­la­tion and par­tial an­a­lyze.

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

Ref­er­ences: