How to put Multiple line comments in Linux Shell Script.

By default shell script can be comments with  prefixing  #  character But when you want to use multiple line comments you use this syntax

  :<space> ‘
your comments
‘                        

For Example we write a shell script for creating user and now we run this script without  comments

#!/bin/bash 

echo -n  “How many user u want to create : ”
read nm
for (( i =1; i<=nm;i++ ))
do
echo -n “Enter user name :”
read usr
useradd “$usr”
passwd “$usr”
chage -d 0  “$usr”
echo “”
echo “……………….”
echo “”
done
echo “User create successfully!!!”

 

 OUTPUT:

 

[root@localhost ~]# ./userc.sh
How many user u want to create……  1
Enter user name….  John
Changing password for user John.
New password:
BAD PASSWORD: it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.

……………….

User create successfully!!!
[root@localhost ~]#

And now we comment the whole   for loop block 

#!/bin/bash 

echo -n  “How many user u want to create : ”
read nm
: ‘    for (( i =1; i<=nm;i++ ))
do
echo -n “Enter user name :”
read usr
useradd “$usr”
passwd “$usr”
chage -d 0  “$usr”
echo “”
echo “……………….”
echo “”
done ‘
echo “User create successfully!!!”

  OUTPUT:

 [root@localhost ~]# ./userc.sh
How many user u want to create……  1
User create successfully!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s