<aside>
💡 What is Bash Script?
- "bash" and "bash script" refer to the same thing.
- "Bash" is the name of the Unix shell.
- It is a command-line interpreter that allows users to interact with the OS.
- "Bash script" refers to a script written in the Bash programming language.
- It is used to automate tasks and execute commands in the Unix environment.
- Remember, python can be written through cli, but also can be coded in .py file.
- Similarly bash can be written in cli and coded in .sh files.
</aside>
Debugging
set -x
./myscript.sh
- Type help set to get more info
- Set or unset values of shell options and positional parameters.
-x flag to print commands and their arguments as they are executed.
- Using
+ instead of - causes these flags to be turned off.
Combining conditions
[ $a -gt 3 ] && [ $a -lt 7 ] — true if $3 <\ a <\ 7$
[ $a -le 3 ] || [ $a -ge 7 ] — true if $a >\ 7$ or $a\ <\ 3$
Shell arithmetic
