Skip to content

Instantly share code, notes, and snippets.

@mathiasgrimm
Created October 13, 2016 09:58
Show Gist options
  • Save mathiasgrimm/f705594a86446365c8a589aefb9584ee to your computer and use it in GitHub Desktop.
Save mathiasgrimm/f705594a86446365c8a589aefb9584ee to your computer and use it in GitHub Desktop.
# grep will be use if one argument is provided
# eg.: sshs prod
# this will only output hosts that have prod in their name
if [ "$#" -ne 1 ]
then
cat ~/.ssh/config|grep 'Host '|awk -F ' ' '{print $2}'
else
cat ~/.ssh/config|grep 'Host '|awk -F ' ' '{print $2}'|grep $1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment