Shell脚本 注释

版权声明:转载或者应用请注明出处 https://blog.csdn.net/qq_35180983/article/details/82526298

以"#"开头的行就是注释,会被解释器忽略。(除第一行的解释器以外)

shell里没有多行注释,只能每一行加一个#号。


#!/bin/bash

####################################
####################################
##
##  this is my first shell script
##            haha   
##
####################################
####################################

echo "this is my first shell script"

echo "hello world"

#echo "hello 1232343"

注:

如果在开发过程中,遇到大段的代码需要临时注释起来,过一会儿又取消注释,怎么办呢?

每一行加个#符号太费力了,可以把这一段要注释的代码用一对花括号括起来,定义成一个函数,没有地方调用这个函数,这块代码就不会执行,达到了和注释一样的效果。

[root@hadoop01 shell]# vi fist.sh 

#!/bin/bash

####################################
####################################
##
##  this is my first shell script
##
####################################
####################################

echo "this is my first shell script"

echo "hello world"

#echo "hello 1232343"


test(){

echo "this is my first shell script"

echo "hello world"

echo "hello 1232343"

}

[root@hadoop01 shell]# /bin/bash fist.sh 
this is my first shell script
hello world

猜你喜欢

转载自blog.csdn.net/qq_35180983/article/details/82526298