Last active
January 7, 2019 15:42
-
-
Save mfurlend/db74206df5a754ecbe212ce8a33f7337 to your computer and use it in GitHub Desktop.
run command on each host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run command on each host in /etc/hosts and print the output | |
# stop on failure (remove || break to continue on failure) | |
# use a pretty line break to delimit responses | |
# like this: | |
#┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫hostname┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ | |
eachhost () { | |
# ignore line 1 and 5 in /etc/hosts | |
for host in $(sed 1,5d /etc/hosts|awk '{print $2}') | |
do | |
( | |
mid=$(( ($(tput cols) / 2) - (($(echo $host | wc -m) + 2) /2 ))) && _hr=$(printf "%*s" $(( $(tput cols) - 2 ))) && echo -en ┏${_hr// /${2-━}}┓ && echo -e "\r\033[${mid}C┫${host}┣" && ssh $host "$*" | |
) || break | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment