linux 指令碼 for 與while實際中的區別
用for 讀取伺服器列表,空格間隔
for h in `cat a`; do ssh } 'chkconfig --level 35 ntpd on && chkconfig --list ntpd && service ntpd status && ntpq -n -p' ;done
#以下命令每讀取一行IP地址,如果不執行ssh命令while正常執行,如果執行的是ssh命令,則只有第一個IP地址成功完成ssh命令
cat a | while read ip ; do command ;done
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8806316/viewspace-1060512/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 實際操作中命令 su 與 sudo 的區別(轉)
- nginx中的break與last指令區別NginxAST
- shell指令碼:$(())與$()還有${}的區別指令碼
- 【js迴圈語句】for與while的區別JSWhile
- while中的continue和if中的continue的區別While
- Linux shell指令碼中內聯輸入 <<- EOF和 <<EOF的區別Linux指令碼
- for(;;)和while(true)的區別While
- do-while語句和while的區別While
- while read line 與for迴圈的區別While
- linux中fork()與vfork()的區別Linux
- shell指令碼頭,#!/bin/sh與#!/bin/bash的區別.指令碼
- 【shell】while read line 與for迴圈的區別While
- linux shell 中 printf 與 echo的區別Linux
- Slackware啟動指令碼與System V啟動指令碼的區別何在?(轉)指令碼
- Linux Shell指令碼程式設計while語句案例Linux指令碼程式設計While
- Java之for(;;)和while(true)的區別JavaWhile
- Linux free中buffer與cache區別Linux
- Linux中檔案與目錄的區別Linux
- 詳解shell中source、sh、bash、./執行指令碼的區別指令碼
- Javascript中“==”與“===”的區別JavaScript
- js中“==”與"==="的區別JS
- linux原始碼包與RPM包的區別Linux原始碼
- [Shell] 指令碼案例(1)--while,for,RANDOM,case指令碼Whilerandom
- SCSS @while指令CSSWhile
- linux shell指令碼中 =~ 的作用Linux指令碼
- linux cache與buffer的區別Linux
- Linux su與sudo的區別Linux
- Java中(==)與equals的區別Java
- numpy中dot與*的區別
- Python中 ‘==‘ 與‘is‘的區別Python
- shell 指令碼中雙引號、單引號、反引號的區別指令碼
- Unity3D指令碼中Start()和Awake()的區別對比分析Unity3D指令碼
- cookie與session的區別以及在Django中的實現CookieSessionDjango
- Linux/Unix shell 指令碼中呼叫SQL,RMAN指令碼Linux指令碼SQL
- 編譯語言、解釋語言與指令碼語言之間的區別編譯指令碼
- js中!和!!的區別與用法JS
- js中 let 與 var 的區別JS
- HTTP中GET與POST的區別HTTP