Hoxt.com – Open Source Mirrors Apache, CPAN, PHP, MySQL, PuTTY, Linux Virtual Server, Linux Documentation Project, ProFTPD

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"

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.