- 论坛徽章:
- 7
|
abs第三章,篇幅有点长,贴了一小段,最好自己看- Chapter 3. Special Characters
- What makes a character special? If it has a meaning beyond its literal meaning, a meta-meaning, then we refer
- to it as a special character.
- Special Characters Found In Scripts and Elsewhere
- #
- Comments. Lines beginning with a # (with the exception of #!) are comments and will not be
- executed.
- # This line is a comment.
- Comments may also occur following the end of a command.
- echo "A comment will follow." # Comment here.
- # ^ Note whitespace before #
- Comments may also follow whitespace at the beginning of a line.
- # A tab precedes this comment.
- 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. Use a new
- line for the next command.
- Of course, 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.
- echo The # here begins a comment.
- echo ${PATH#*:} # Parameter substitution, not a comment.
- echo $(( 2#101011 )) # Base conversion, not a comment.
- # Thanks, S.C.
- The standard quoting and escape characters (" ' \) escape the #.
- Certain pattern matching operations also use the #.
- ;
- Command separator [semicolon]. Permits putting two or more commands on the same line.
- echo hello; echo there
- if [ -x "$filename" ]; then # Note that "if" and "then" need separation.
- # Why?
- echo "File $filename exists."; cp $filename $filename.bak
- else
- echo "File $filename not found."; touch $filename
- fi; echo "File test complete."
复制代码 |
|