linux_wiki:bash_scripting_snippets

This is an old revision of the document!


Bash Scripting Snippets

General Information

Bash scripting references and snippets.

Checklist

  • 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:

END=10
for i in $(seq 1 $END); do 
  echo $i
done

  • linux_wiki/bash_scripting_snippets.1572922885.txt.gz
  • Last modified: 2019/11/04 22:01
  • by billdozor