2014年7月22号(shell学习二)
今天给大家介绍一下shell的特殊字符
(1)#:comments.Lines beginning with a# are comments and will not be executed
注意点:1.Comments may also occur following the end of a command
example:echo "A comment will follow." # Comment here. Note whitespace berfore #
2.Comments may also follow whitespace at the beginning of a line
3.comments may even be embedded within a pipe
note: 1. A command may not follow a comment on the same line.There is no method of terminating the comment,in order for "live code" to begin on the same line.You can use a new line for the command
2.Of course,a quoted or an escaped # in an echo statement does not begin a comment.Likewise,a # appears in certain parameter-substitution constructs and in numerical constant expressions
echo "The # here does not begin a comment."
echo 'The # here does not begin a comment.'
echo The \# here does not begin a comment.
(2); Command separator.Permits putting two putting two or more commands on the same line.
example :echo hello; echo there # Note the space after the semicolon.
(3);;
Terminator in a case option
example:
#/bin/bash
variable="abc"; Note:这里没有空格在等号的左右两边
case "$variable" in
abc) echo "\$variable = abc" ;;
xyz) echo "\$variable = xyz" ;;
esac
(4).
1."dot" command.Equivalent to source
2."dot" , as a component of a filename.When working with filenames,a leading dot is the prefix of a "hidden" file,afile that an ls will not normally show.
3.When considering directory names,a single dot represents the current working directory,and two denote the parent directory
(5)
"partial quoting."STRING" preserves(from interpretation)most of the special characters within STRING.