Bash CommentsIn this topic, we will understand how to insert comments in a Bash Script file. Comments are the necessary part of any programming language. They are used to define the usage of any code or function. Comments are the strings which help in the readability of a program. They are not executed when we execute the commands in Bash Script file. Bash script provides support for two types of comments, just like the other programming language.
Bash Single Line CommentTo write single line comment in bash, we have to use hash (#) symbol at the starting of the comment. Following is an example of Bash Script which contains single-line comments in between commands: Bash Script Bash Console View The above script will look like the following image in the Bash console: Output If we enter a name as javatpoint, then the output will look like this: Here, it can be clearly seen that comments are ignored while the execution of the commands is in process. Bash Multi Line CommentThere are two ways to insert multi-line comments in bash scripts:
Read the following examples which will help you to understand both the ways of multi-line comments: Method 1: Bash Script Bash Console View Output Method 2: Bash Script Bash Console View Output ConclusionIn this topic, we discussed how to insert a single line and multi-line comments in Bash Script file. Next TopicBash Quotes |