Difference between revisions of "Bash loops"
From Tech-Wiki
Line 4: | Line 4: | ||
# for num in {1..5}; do ssh host-$num "shutdown"; done | # for num in {1..5}; do ssh host-$num "shutdown"; done | ||
# for host in `cat hosts.txt`; do ssh $host "shutdown"; done | # for host in `cat hosts.txt`; do ssh $host "shutdown"; done | ||
+ | # while read LINE; do COMMAND $LINE; done < FILE | ||
Executing the same command forever | Executing the same command forever | ||
# while true; do date +%s; done | # while true; do date +%s; done |
Revision as of 20:47, 14 November 2018
Executing a Do loop to repeat one command with different hosts
# for num in {1..5}; do ssh host-$num "shutdown"; done # for host in `cat hosts.txt`; do ssh $host "shutdown"; done # while read LINE; do COMMAND $LINE; done < FILE
Executing the same command forever
# while true; do date +%s; done