Linux查看檔案及內容處理:管道符命令說明及執行個體,linux管道

來源:互聯網
上載者:User

Linux查看檔案及內容處理:管道符命令說明及執行個體,linux管道
1、命令說明:

Linux中的管道符“|”,實際它是一個固定大小的緩衝區,大小為4K位元組。其功能可以把一個命令的輸出內容當做下一個命令的輸入內容,兩個命令之間只需要使用管道符串連即可。

2、執行個體:

比如,如果想要查看一下 /usr/sbin 目錄下檔案的詳細資料,可以使用 ls -l /usr/local 命令,不過這可能會出現因輸出內容過多而造成翻屏的情況,這樣一來,先輸出的內容在螢幕上看不到了。其實這裡就可以利用管道功能,將命令的輸出使用 more 程式一頁一頁地顯示出來。

[root@CentOS sbin]# ls -l /usr/sbin/ | more總用量 60976-rwxr-xr-x. 1 root root       11240 12月  2 2016 abrt-auto-reporting-rwxr-xr-x. 1 root root       32408 12月  2 2016 abrt-configuration-rwxr-xr-x. 1 root root       31968 12月  2 2016 abrtd-rwxr-xr-x. 1 root root       31968 12月  2 2016 abrt-dbus-rwxr-xr-x. 1 root root        1347 12月  2 2016 abrt-harvest-pstoreoops-rwxr-xr-x. 1 root root        9671 12月  2 2016 abrt-harvest-vmcore-rwxr-xr-x. 1 root root        2914 12月  2 2016 abrt-install-ccpp-hook-rwxr-xr-x. 1 root root       27752 12月  2 2016 abrt-serverlrwxrwxrwx. 1 root root          10 1月  30 14:38 accept -> cupsaccept-rwxr-xr-x. 1 root root       11720 6月  10 2014 accessdb-rwxr-xr-x. 1 root root       11456 11月  6 2016 accton-rwxr-xr-x. 1 root root      135136 11月  6 2016 adcli-rwxr-xr-x. 1 root root        3126 10月  4 2013 addgnupghome-rwxr-xr-x. 1 root root       15864 11月  6 2016 addpartlrwxrwxrwx. 1 root root           7 1月  30 14:34 adduser -> useradd-rwxr-xr-x. 1 root root       36864 11月  6 2016 agetty-rwxr-xr-x. 1 root root        3018 11月  7 2016 alsabat-test.sh--More--

如上所示,通過管道,使 ls -l /usr/sbin 命令輸出的內容做為下一個命令 more 的輸入,這樣就可以方便地查看輸出內容了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.