shell中的引用

來源:互聯網
上載者:User

 

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 \=

  =

 有些輸出我也不知道那就試試了反正就幾次結果就出來了

本文出自 “君子博學而日參省乎己..” 部落格

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.