linux_wiki:bash_scripting_snippets

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
linux_wiki:bash_scripting_snippets [2018/06/16 15:17]
billdozor created
linux_wiki:bash_scripting_snippets [2019/11/04 22:02] (current)
billdozor [Loop over a sequence]
Line 14: Line 14:
 Different ways to generate random numbers. Different ways to generate random numbers.
  
 +\\
 Random 2 Digit Number<code bash>echo ${RANDOM:0:2}</code> Random 2 Digit Number<code bash>echo ${RANDOM:0:2}</code>
  
 \\ \\
 Random number that is a minimum of 1 and max of 100<code bash>echo $[ (RANDOM % 100) + 1]</code> Random number that is a minimum of 1 and max of 100<code bash>echo $[ (RANDOM % 100) + 1]</code>
 +
 +----
 +
 +====== Loop over a sequence ======
 +
 +To perform a loop similar to a c++ for loop:
 +
 +<code bash>
 +END=10
 +for i in $(seq 1 ${END}); do 
 +  echo ${i}
 +done
 +</code>
  
 ---- ----
  
  • linux_wiki/bash_scripting_snippets.1529176645.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)