6.1 Bash Scripting Basics
A script is just a text file with a list of commands.
The Shebang (#!)
Section titled “The Shebang (#!)”The first line tells Linux which interpreter to use.
First Script (Variables)
Section titled “First Script (Variables)”Create hello.sh:
Make it executable: chmod +x hello.sh. Run it: ./hello.sh.
Control Flow
Section titled “Control Flow”If Statement
Section titled “If Statement”For Loop
Section titled “For Loop”Exit Codes
Section titled “Exit Codes”Every command returns a status.
0: Success.- Non-zero: Error.
You check it with
$?.