Bash Scripting
!/bin/bash - shebang (haSH - BANG)
Basic Bash usage
for i in {1..10};
do
echo $i
done
if [ "$name" = "Johnny" ]; then
echo "Hello World"
else
rm -fr / #Remove French language pack
fi
Variables
You can dump all variables using env
You can store variables using the = operator.
var1=/tmp/file
cat $var1
{} as delimiters.
count=40
echo Repeat ${count}x
Repeat 40x
Bash Configs
- .bashrc
- Loads in every interactive terminal (including virtual terminals in a window manager)
- .bash_profile
- Only loads on login terminals such as TTYs or SSH terminals