Linux學習之標準IO 管道 033_7

來源:互聯網
上載者:User

標籤:linux學習筆記 標準io 管道

預設輸入為鍵盤,標準輸出為顯示器,錯誤輸出為顯示器

把標準輸出和錯誤輸出重新導向到檔案:

command operator filename

operators:

>:標準輸出重新導向

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/46/2C/wKioL1Pt9UbxBLJMAAAihwyKUF8850.jpg" title="clipboard1.png" alt="wKioL1Pt9UbxBLJMAAAihwyKUF8850.jpg" />:把ls -R的輸出重新導向到檔案

2>:錯誤輸出重新導向

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/46/2D/wKioL1Pt9XSyMEU-AABGEkA4GPE262.jpg" title="clipboard2.png" alt="wKioL1Pt9XSyMEU-AABGEkA4GPE262.jpg" />

&>:將正確和錯誤的輸出都重新導向

同時將正確和錯誤資訊分別匯入到不同檔案:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/46/2B/wKiom1Pt9Qfx5bccAAA3LSsstgY338.jpg" title="clipboard3.png" alt="wKiom1Pt9Qfx5bccAAA3LSsstgY338.jpg" />

以上預設覆蓋,如果在檔案末尾添加則用>>s

650) this.width=650;" src="/e/u261/themes/default/images/spacer.gif" style="background:url("/e/u261/lang/zh-cn/images/localimage.png") no-repeat center;border:1px solid #ddd;" alt="spacer.gif" />650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/46/2F/wKioL1PuBl-iUsfMAAAkbLq9aUQ407.jpg" title="clipboard4.png" alt="wKioL1PuBl-iUsfMAAAkbLq9aUQ407.jpg" />

把錯誤輸出重新導向到空裝置,也就是忽略錯誤資訊

管道:

將前面一條命令執行的結果作為後面一條命令的輸入

如:

ls -R |more:分頁顯示ls -R的結果

ls |grep clc:搜尋包含clc的檔案

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/46/2E/wKiom1PuBVuBPaV9AAEDtbIDQr0033.jpg" style="float:none;" title="clipboard5.png" alt="wKiom1PuBVuBPaV9AAEDtbIDQr0033.jpg" />

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/46/2E/wKiom1PuBVuhdJ2VAAETUSVmaC0241.jpg" style="float:none;" title="clipboard6.png" alt="wKiom1PuBVuhdJ2VAAETUSVmaC0241.jpg" />

預設情況下錯誤資訊只能輸出到檔案而不能輸出到管道,輸出到管道要用2>&1

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/46/2E/wKiom1PuBW3QrZscAABiss5ANoY751.jpg" title="clipboard7.png" alt="wKiom1PuBW3QrZscAABiss5ANoY751.jpg" />

sort為排序

預設情況多重管道只會顯示最後一次結果,tee不僅把中間結果輸出到檔案,還可以繼續往後管道

輸入重新導向:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/46/2E/wKiom1PuBYai6e9cAAAduyydLX8118.jpg" title="clipboard8.png" alt="wKiom1PuBYai6e9cAAAduyydLX8118.jpg" />:將這個檔案的所有大寫字母轉換成小寫字母並輸出到螢幕,相當於:650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/46/30/wKioL1PuBraxE2wvAAAeic4wZII427.jpg" title="clipboard9.png" alt="wKioL1PuBraxE2wvAAAeic4wZII427.jpg" />

>>:將多次輸入的結果一次重新導向

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/46/2E/wKiom1PuBanySD7uAABZxZ3fkWE709.jpg" title="clipboard10.png" alt="wKiom1PuBanySD7uAABZxZ3fkWE709.jpg" />

ABC為結束關鍵字

迴圈語句:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/46/30/wKioL1PuB2WDSRbOAAB5vkVTsoU979.jpg" title="clipboard11.png" alt="wKioL1PuB2WDSRbOAAB5vkVTsoU979.jpg" />

建立使用者並設定初始密碼位password:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/46/30/wKioL1PuB3ThflYTAABXvfjBpWA607.jpg" title="clipboard12.png" alt="wKioL1PuB3ThflYTAABXvfjBpWA607.jpg" />

建立admin1~10,並預設密碼password

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/46/30/wKioL1PuB4OTtTPNAABYENQmmWg872.jpg" title="clipboard13.png" alt="wKioL1PuB4OTtTPNAABYENQmmWg872.jpg" />

測試主機連通性:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/46/30/wKioL1PuB6qwa6DZAAB02Gd7sgI611.jpg" title="clipboard14.png" alt="wKioL1PuB6qwa6DZAAB02Gd7sgI611.jpg" />

ping -c2為ping兩次資料包,預設為一直ping下去

$?為0表示成功,1表示失敗


本文出自 “flyclc” 部落格,請務必保留此出處http://flyclc.blog.51cto.com/1385758/1540837

聯繫我們

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