Bash Scripting Snippets

General Information

Bash scripting references and snippets.


  • Distro agnostic

Random Numbers

Different ways to generate random numbers.

Random 2 Digit Number

echo ${RANDOM:0:2}

Random number that is a minimum of 1 and max of 100

echo $[ (RANDOM % 100) + 1]

Loop over a sequence

To perform a loop similar to a c++ for loop:

for i in $(seq 1 ${END}); do 
  echo ${i}

  • linux_wiki/bash_scripting_snippets.txt
  • Last modified: 2019/11/05 03:02
  • by billdozor