代表注释,如果有一行以#开始,那么意味着这行不会被执行,只是一行说明注释。
例如:
# this is comments 这是一行注释。
但是这里有个例外,那就是脚本的第一行我们经常看到的:
#!/bin/bash 这个指示一个脚本的解释器,说明这个脚本是由/bin/bash 来解释的。
从#为开始,后面的字符即为注释,直到该行结束。体会下面几个例子:
echo "The # here does not begin a comment."
echo 'The # here does not begin a comment.'
引用内的字符按原意输出。
echo The \# here does not begin a comment. 这个使用了\把#做了转义,即把#原样输出。
echo The # here begins a comment. 这个惨了,被截断了,只输出: The
echo ${PATH#*:} 这个是参数替换,不是注释符。
echo $(( 2#101011 )) 这个是基数指示符,也不是注释符,说明后面的数是二进制的。
# The name of this function is :
当然在函数内部,它可以做一个占位符,这样函数就不是一个空函数了。
not_empty ()
{
:
} # Contains a : (null command), and so is not empty.
下面的这个比较实用:
{a..z} 生成字符a到z之间的所有字符,当然也可以是数字,比如:{1..9}
体会下这个代码
echo {a..z} # a b c d e f g h i j k l m n o p q r s t u v w x y z
# Echoes characters between a and z.
echo {0..3} # 0 1 2 3
# Echoes characters between 0 and 3.
base64_charset=( {A..Z} {a..z} {0..9} + / = )
# Initializing an array, using extended brace expansion.
# From vladz's "base64.sh" example script.
上面解释了一些Bash Shell中的部分特殊字符,在