<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # 第五章 引用 ### 本章目錄 - [5.1 引用變量](05_1_quoting_variables.md) - [5.2 轉義](05_2_escaping.md) --- 引用就是將一個字符串用引號括起來。這樣做是為了保護Shell/Shell腳本中被重新解釋過或帶擴展功能的[特殊字符](http://tldp.org/LDP/abs/html/special-chars.html)(如果一個字符帶有其特殊意義而不僅僅是字面量的話,這個字符就能稱為“特殊字符”。比如星號“*”就能表示[正則表達式](http://tldp.org/LDP/abs/html/regexp.html#REGEXREF)中的一個[通配符](http://tldp.org/LDP/abs/html/globbingref.html))。 ``` bash$ ls -l [Vv]* -rw-rw-r-- 1 bozo bozo 324 Apr 2 15:05 VIEWDATA.BAT -rw-rw-r-- 1 bozo bozo 507 May 4 14:25 vartrace.sh -rw-rw-r-- 1 bozo bozo 539 Apr 14 17:11 viewdata.sh bash$ ls -l '[Vv]*' ls: [Vv]*: No such file or directory ``` > 可以看到,提示不存在該文件。這里的`'[Vv]*`被當成了文件名。 > 在日常溝通和寫作中,當我們引用一個短語的時候,我們會將它單獨隔開并賦予它特殊的意義,而在bash腳本中,當我們*引用*一個字符串,意味著保留它的*字面量*。 很多程序和公用代碼會展開被引用字符串中的特殊字符。引用的一個重用用途是保護Shell中的命令行參數,但仍然允許調用的程序擴展它。 ``` bash$ grep '[Ff]irst' *.txt file1.txt:This is the first line of file1.txt. file2.txt:This is the First line of file2.txt. ``` > 在所有.txt文件中找出包含first或者First字符串的行 注意,不加引號的 `grep [Ff]irst *.txt` 在Bash下也同樣有效。[^1] 引用也可以控制[echo](http://tldp.org/LDP/abs/html/internal.html#ECHOREF)命令的斷行符。 ``` bash$ echo $(ls -l) total 8 -rw-rw-r-- 1 bo bo 13 Aug 21 12:57 t.sh -rw-rw-r-- 1 bo bo 78 Aug 21 12:57 u.sh bash$ echo "$(ls -l)" total 8 -rw-rw-r-- 1 bo bo 13 Aug 21 12:57 t.sh -rw-rw-r-- 1 bo bo 78 Aug 21 12:57 u.sh ``` [^1]: 前提是當前目錄下有文件名為First或first的文件。這也是使用引用的另一個原因。(感謝 Harald Koenig 指出了這一點)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看