Skip to content

Instantly share code, notes, and snippets.

@arkag
Created September 29, 2021 21:09
Show Gist options
  • Save arkag/1a6b26add167777fb88cbd859e731c17 to your computer and use it in GitHub Desktop.
Save arkag/1a6b26add167777fb88cbd859e731c17 to your computer and use it in GitHub Desktop.
Useful if you need to run a single command or one liner on many machines and you don't want to wear out your fancy new NovelKey Cream Launch Edition switches just yet...
# ssh, but t h i c c
function sshhh
set range_arr (string split '-' (string trim --chars=[] (string match -r "\[[0-9]*-[0-9]*\]" $argv[1])))
set range_start "$range_arr[1]"
set range_end "$range_arr[2]"
set base_hostname (string replace -r -a '\[[0-9]*-[0-9]*\]' '' $argv[1])
for target_host in (seq -f "$base_hostname%g" $range_start $range_end)
set argv[1] "$target_host"
command ssh $argv
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment