shell中的引用


 

shell中的引号

1.双引号

  $,`,\,保留特殊意义

  注意echo不加参数默认不支持\n这种转义字符

  printf支持

  [root@Centos5 test]# echo "\n"

  \n

  [root@Centos5 test]#

  [root@Centos5 test]# printf "\n"

 

  [root@Centos5 test]#

 注意在双引号中引用特殊字符echo "\特殊字符"

 #双引号中已知特殊字符$`\"四个

  echo "\""

  "

  echo "\$"

  $

2.单引号

  引用的字符解释为字符表面意思 

  注意echo -e时不论是单引号还是双引号中都会解释\n等转义字符

  转义字符表

  \\ \a \b \c \f \n \t \r \v

  # 不要和\$混淆

  [root@Centos5 test]# echo -e "\n"

 

  [root@Centos5 test]#

  [root@Centos5 test]# echo -e '\n'

 

  [root@Centos5 test]# echo -e '\"'

  \"

  再有

  [root@Centos5 test]# echo -e '\'

  \

  [root@Centos5 test]# echo -e '\\'

  \

  [root@Centos5 test]# echo \

  >

 不要迷惑哦

3.统配符号

  不要引起来用*?[]|^,如果匹配不到则解释为自身

 

  [root@Centos5 test]# ls *.111

  ls: *.111: No such file or directory

4.转义\,\后面紧接的字符解释为字面意思

  echo \*

  *

  echo \\

  \

5.shell元字符meta

  IFS

  CR

  =

  $

  >

  <|&(){};&&||!

  #这些字符不被引用时需要转义

  echo \=

  =

 有些输出我也不知道那就试试了反正就几次结果就出来了

本文出自 “君子博学而日参省乎己..” 博客

相关内容

    暂无相关文章