Clarity
Helps others (and yourself) understand what the script does.
Shell Script · Comments
Shell Scripting · Lesson 5
Use comments to document shell scripts properly. Single line and multi line comment techniques. Writing readable production scripts. Industry standard documentation style.
A comment is a line of text that is ignored by the shell. It is used to explain code, add notes, or temporarily disable commands.
Comments improve readability and make scripts easier to maintain.
Helps others (and yourself) understand what the script does.
Makes it easier to modify scripts later.
You can disable lines temporarily during testing.
Shell scripting mainly supports single-line comments. Multi-line comments are simulated using special techniques.
Use # to add a comment on a single line. The shell ignores everything after #.
Comments can also appear after a command on the same line.
Shell does not have real multi-line comments, but this is a common workaround.
Each line must start with # for a block-style comment.
Next lesson: Variables in Shell Scripting