Single-line and multiline comments in the shell

Source: Internet
Author: User

2017-10-04 Add background account:

Suse10, Huawei Veneer, the first four methods are small white in the actual Linux environment test results, may be the difference between Linux version, and not all scenarios are compatible ... Another small white 201 May-January has been formally transformed into Java development, the existing company's information security is not csdn, some feedback compared with the delay ... It is hereby stated that ....


1. Single note

As we all know, # like to comment: Echo ' ni '

# echo ' ni '

2. Multi-line Comment:

Law I:

: <<!

Statement 1

Statement 2

Statement 3

Statement 4

!

For example:

LINUX101:/HOME/WSJ # sh Dian
Ni
Ni
Ni
Ni
Ni
Ni

LINUX101:/HOME/WSJ # More Dian
#!/bin/ksh
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"

: <<!
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
!

Law II:

: '

Statement 1

Statement 2

Statement 3

Statement 4

'

For example:

LINUX101:/HOME/WSJ # sh Dian
Ni
Ni
Ni
Ni
Ni
Ni

LINUX101:/HOME/WSJ # More Dian
#!/bin/ksh
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"

: '
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
'

2014-02-03-06 added:

Law III:

If false; Then

Statement 1

Statement 2

Statement 3

Statement 4

Fi

LINUX101:/HOME/WSJ # sh Dian
Ni
Ni
Ni
Ni
Ni
Ni

LINUX101:/HOME/WSJ # More Dian
#!/bin/ksh
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"

If false; Then
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
echo "Ni"
Fi

Law four:

: << character #这里的字符可以是数字或者是字符都可以

Statement 1

Statement 2

Statement 3

Statement 4

Character

2014-09-10 Happy teachers ' day, supplemented by Chaosink buddies and Dablelv buddies 2017-09-27:

Law Five:

((0)) && {

Statement 1

Statement 2

Statement 3

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.