<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          基本命令學(xué)習(xí) -(2)查看文件內(nèi)容的六種方法

          共 1417字,需瀏覽 3分鐘

           ·

          2021-02-21 05:22

          公眾號(hào)關(guān)注?「開(kāi)源Linux
          回復(fù)「學(xué)習(xí)」,有我為您特別篩選的學(xué)習(xí)資料~

          查看文件內(nèi)容


          1. cat

          描述:查看文件內(nèi)容
          用法:cat [選項(xiàng)]...[文件]...
          選項(xiàng):
          -n 顯示行號(hào),包括空白行
          -b 顯示行號(hào),空白行不顯示行號(hào)
          [root@qll?~]#?cat?/etc/passwd
          [root@qll?~]#?cat?-n?/etc/passwd
          [root@qll?~]#?cat?-b?/etc/passwd

          2. more

          more命令和cat的功能一樣都是查看文件里的內(nèi)容,但有所不同的是more可以按頁(yè)來(lái)查看文件的內(nèi)容,還支持直接跳轉(zhuǎn)行等功能。

          常見(jiàn)用法:
          • Enter鍵:向下n行,需要定義。默認(rèn)為1行

          • 空格鍵:向下滾動(dòng)一屏

          • Ctrl+B:返回上一屏

          • = 輸出當(dāng)前行的行號(hào)

          • V 調(diào)用vi編輯器

          • !命令 調(diào)用Shell,并執(zhí)行命令

          • q 退出more

          [root@qll?~]#?more?/var/log/messages

          3. less

          描述:分頁(yè)查看文件內(nèi)容,空格(下一頁(yè))、方向鍵(上下回翻)、q鍵(退出查看)。

          [root@qll?~]#?less?/var/log/mingongge.log

          4. head

          描述:查看文件頭部?jī)?nèi)容,默認(rèn)顯示前10行。
          用法:head [選項(xiàng)]...[文件]...
          選項(xiàng):
          -c nK 顯示文件前nKB的內(nèi)容。
          -n 顯示文件前n行的內(nèi)容。
          [root@qll?~]#?head?-c?2k?/var/log/messages?#查看文件的前2KB的內(nèi)容
          [root@qll?~]#?head?-n?15?/var/log/messages?#查看文件的前15行的內(nèi)容

          5. tail

          描述:查看文件的尾部?jī)?nèi)容,默認(rèn)顯示末尾10行。
          用法:tail [選項(xiàng)]...[文件]...
          選項(xiàng):
          -c nK 顯示文件末尾nKB的內(nèi)容。
          -n 顯示文件末尾n行的內(nèi)容。
          -f 動(dòng)態(tài)顯示文件內(nèi)容,常用于查看日志,按 Ctrl+C 組合鍵退出。
          [root@qll?~]#?tail?-c?2KB?/var/log/messages?#查看文件末尾2KB的內(nèi)容
          [root@qll?~]#?tail?-n?15?/var/log/messages??#查看文件末尾15行的內(nèi)容
          [root@qll?~]#?tail?-f?/var/log/messages?????#實(shí)時(shí)動(dòng)態(tài)查看文件內(nèi)容

          6. grep

            描述:查找關(guān)鍵詞并打印匹配的行。
          用法:grep [選項(xiàng)] 匹配模式 [文件]...
          常用選項(xiàng):
          -i 忽略大小寫(xiě)。
          -v 取反匹配
          [root@qll?~]# grep root /etc/passwd ???#在passwd文件中過(guò)濾出包含`root`的行。
          [root@qll?~]#?grep?-i?ROOT?/etc/passwd?#過(guò)濾出包含`ROOT`的行(不區(qū)分大小寫(xiě))
          [root@qll?~]# grep -v root /etc/passwd #過(guò)濾出不包含`root`的行。

          關(guān)注「開(kāi)源Linux」加星標(biāo),提升IT技能

          瀏覽 52
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  黄91网站 | 国产免费AV片在线无码免费看 | 九九色色九九 | 蜜桃视频在线观看18 | 精品无码人妻一区二区 |