欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          SHELL 讀取文件的每一行內(nèi)容并輸出

          假設(shè)讀取的文件為當(dāng)期目錄下的 test.txt 文件,內(nèi)容如下:

          Google   Runoob  Taobao

          實例 1

          #!/bin/bash

          while read line
          do
              echo $line
          done < test.txt

          執(zhí)行輸出結(jié)果為:

          Google  Runoob  Taobao

          實例 2

          #!/bin/bash

          cat test.txt | while read line
          do
              echo $line
          done

          執(zhí)行輸出結(jié)果為:

          Google  Runoob  Taobao

          實例 3

          for line in `cat  test.txt`
          do
              echo $line
          done

          執(zhí)行輸出結(jié)果為:

          Google  Runoob  Taobao

          for 逐行讀和 while 逐行讀是有區(qū)別的,如:

          $ cat test.txt
          Google
          Runoob
          Taobao

          $ cat test.txt | while read line; do echo $line; done
          Google
          Runoob
          Taobao

          $ for line in $(<test.txt); do echo $line; done
          Google
          Runoob
          Taobao

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號