Jump to content

Bash (Unix shell): Difference between revisions

Line 16: Line 16:


===Basic If Statements===
===Basic If Statements===
[https://linuxize.com/post/bash-if-else-statement/ https://linuxize.com/post/bash-if-else-statement/]
<syntaxhighlight lang="bash">
if [[ $VAR -gt 10 ]] then
  echo "The variable is greater than 10."
elif [[ $VAR -eq 10 ]] then
  echo "The variable is equal to 10."
else
  echo "The variable is less than 10."
fi
</syntaxhighlight>


 
===Comparisons===
===Comparisons
* <code>-eq</code> is <code>==</code>
* <code>-eq</code> is <code>==</code>
* <code>-gt</code> is <code>></code>
* <code>-gt</code> is <code>></code>