shell 命令列語句

來源:互聯網
上載者:User

標籤:

第一步:
ssh免密碼登陸【用公開金鑰,私密金鑰】

第二步:

#!/bin/bashwhile read server;do        ssh -n $server "[email protected]" 2>&1 |sed "s/^/$server: /" &donewait

 

./bunsan2.sh free < servers.txt

注釋:while read server 把輸入的內容當做變數 server

-n ssh的選項,不進行標準輸入的讀取。

"[email protected]" 進行迴圈 。

2 >&1 如果沒有這個命令,ssh 命令寫入到標準錯誤輸出的內容就不會傳遞給sed命令。它的作用就是 將標準錯誤輸出的開頭指定為標準輸入相同。

& 幕後處理。如果不這樣的話, 一條命令執行過長,才能執行後面一條命令。

第三步:

servers.txt檔案裡面的內容

[email protected]58.241.41.141[email protected]58.241.41.142[email protected]58.241.41.143

 ./bunsan2.sh free < servers.txt

就可以看到三排結果了。

./bunsan2.sh free < servers.txt >dgx.txt 或者這樣,繼續重新導向。

 

shell 命令列語句

相關文章

聯繫我們

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