7Jul/100
shell scripting – Bash alias that takes argument
Normally, you would have this shortcut in .bash_profile
alias sshwww='ssh john@www.example.com'
What about you have 100s of www servers:
sshwww() { ssh "john@$1".example.com; }
Usage: "sshwww web1", "sshwww web2"
Even more, you can su directly to root from john:
sshroot() { ssh "john@$1".example.com "su"; }
Usage: "sshroot web1", "sshroot web2"
Leave a comment