next up previous contents
Next: 基本的系統設定 Up: 正規表示法與管線處理 Previous: 資料流重導向   Contents

管線命令 (pipe)

  • 管線命令的處理

    \begin{picture}(150,35)
\put(0,5){\dashbox{1}(30,12){command1}}
\put(55,5){\dash...
...r(0,-1){11}}
\put(43,0){\line(0,1){20}}
\put(98,0){\line(0,1){20}}
\end{picture}
    1. 使用cat指令輸出後的內容,以grep找出要看的字串。
      [root@kvm5 ~]# cat /tmp/auto.master | grep misc
      /misc	/etc/auto.misc
      # Note that if there are entries for /net or /misc (as
      
    2. 使用ls指令輸出後的內容,被less讀取,並且利用less的功能前後翻動相關的資訊。
      [root@kvm5 ~]# ls -al /etc | less
      
    3. Examples
      [root@kvm5 ~]# ls /usr/lib64 | grep 'libX11'
      libX11.so.6
      libX11.so.6.3.0
      libX11-xcb.so.1
      libX11-xcb.so.1.0.0
      
      [root@kvm5 ~]# grep '^n.*/sbin/nologin$' /etc/passwd
      nobody:x:99:99:Nobody:/:/sbin/nologin
      nscd:x:28:28:NSCD Daemon:/:/sbin/nologin
      nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
      ntp:x:38:38::/etc/ntp:/sbin/nologin
      nslcd:x:65:55:LDAP Client User:/:/sbin/nologin
      
      [root@kvm5 ~]# grep '^n.*/sbin/nologin$' /etc/passwd | sort
      nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
      nobody:x:99:99:Nobody:/:/sbin/nologin
      nscd:x:28:28:NSCD Daemon:/:/sbin/nologin
      nslcd:x:65:55:LDAP Client User:/:/sbin/nologin
      ntp:x:38:38::/etc/ntp:/sbin/nologin
      
      [root@kvm5 ~]# grep '^n.*/sbin/nologin$' /etc/passwd | sort | mail -s 'dywang test' root@kvm5.deyu.wang
      [root@kvm5 ~]# mail
      Heirloom Mail version 12.4 7/29/08.  Type ? for help.
      "/var/spool/mail/root": 2 messages 2 new
      >N  1 Mail Delivery System  Mon Jan 23 19:19  96/3452  "Undelivered Mail Returned to Sender"
       N  2 root                  Mon Jan 23 19:24  39/1643  "dywang test"
      & 2
      Message  2:
      From root@kvm5.deyu.wang  Mon Jan 23 19:24:16 2012
      Return-Path: <root@kvm5.deyu.wang>
      X-Original-To: root@kvm5.deyu.wang
      Delivered-To: root@kvm5.deyu.wang
      Date: Mon, 23 Jan 2012 19:24:16 +0800
      To: root@kvm5.deyu.wang
      Subject: dywang test
      User-Agent: Heirloom mailx 12.4 7/29/08
      Content-Type: text/plain; charset=us-ascii
      From: root@kvm5.deyu.wang (root)
      Status: R
      
      nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
      nobody:x:99:99:Nobody:/:/sbin/nologin
      nscd:x:28:28:NSCD Daemon:/:/sbin/nologin
      nslcd:x:65:55:LDAP Client User:/:/sbin/nologin
      ntp:x:38:38::/etc/ntp:/sbin/nologin
      
      & q
      Held 2 messages in /var/spool/mail/root
      


2015-04-13