Add a #!/bin/bash
at the top to specify the interpreter (bash, zsh etc.)
Use #
for single-line comments.
variable_name=value
$variable_name
Control Structures - If-Else: if [ condition ]; then # commands elif [ condition ]; then # commands else # commands fi
&&
for logical AND||
for logical OR==
for EQUALS!=
for numerical comparison[ "$str1" != "$str2" ]
for string comparisons for var in list; do
# commands
done
While Loop while [ condition ]; do Commands done
Arrays Declare: array_name=(value1 value2 value3) Access: ${array_name[index]}
random_number=$((RANDOM))
Tip: Start by making the loop and running the script for every iteration.
Tmux (Terminal Multiplexer) is a powerful tool that allows you to create multiple terminal sessions within a single window. It lets you split your terminal into panes, create multiple windows, and most importantly, keep your sessions running even after disconnecting. This is especially useful for remote work and long-running processes.
tmux new -s <name>
tmux a -t <name>
tmux detach
tmux ls
tmux kill-session -t <name>
Note: -a
stands for attach, -t
stands for target
Ctrl + A + |
Ctrl + A + -
Ctrl + B + D