Programming/Bash

From Dev Wiki
< Programming
Revision as of 13:56, 13 February 2020 by Brodriguez (talk | contribs) (Create page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Bash is primarily a Linux scripting language, but it works on all versions of Windows as well, if used through git.

Comments

# This is an inline comment

Variables

Variable Definition

a_bool=true
b_bool=false
my_var="This is a string."

Variable Usage

echo "Printing variable values."
echo $a_bool
echo $b_bool
echo ${my_var_1}${my_var_2}

If Statements

Basic If

if [[ $x == $y ]]
then
    # Logic if true.
fi

Full If

if [[ $x == $y ]]
then
    # Logic for "if" true.
elif [[ $x && ($y || $z) ]]
then
    # Logic for "else if" true.
else
    # Logic for false.
fi