Linux Bash Comments Inline or Outline

Linux bash have a lot of different type of programming features. While using these features we can create very complex scripts or applications in bash. In order to take notes in a script we should use comments. Comments provides useful information for system administrators.

Comment Bash

In bash comments starts with # . In the following example comments can be easily seen that those comments start from beginning of the line. To the end of line all characters are interpreted as comment.

# We will create a test file.

touch test1

#This is another comment

In Line Comments

We can start the comment other than begging. We can write our command and then start comment to the end of line.

#This is a comment.

ls -al #This is a comment too.

Multi line Comments

We can use multi line comments line by line. Actually there is no special form we just put comments line by line like below.

# This is first line comment
# This is second line comment
# This is third line comment

Shell Specification

Most of the shell scripts starts with #!/bin/bash this may seem a comment but it is not. First two letters of a shell file is special. This line specifies the shell type or interpreter used while processing the file. So do not put any comment to this line.

Leave a Comment