1

I am relatively new to using the command line.

I want to create an alias such as "importme" that will do the following:

alias importme="ssh root@server.com << EOF
mysql
list databases;
EOF"

The problem is that using EOF requires pressing ENTER, which is not possible with alias'. My end goal is to create an alias that will import a database into a REMOTE database server from my local machine.

Any ideas on how to create this alias? with or without using EOF? Thanks

Rees
  • 1,757
  • 9
  • 33
  • 50

1 Answers1

2

Instead, create a function an save it in your ~/.bashrc:

importme()
{
   ssh root@server.com << EOF
mysql
list databases;
EOF
}

Source (. ~/.bashrc) and you will be ready to use it with importme.

fedorqui
  • 275,237
  • 103
  • 548
  • 598
  • thanks fedorqui! is there any harm in putting this in ~/.profile instead? – Rees Sep 11 '13 at 22:08
  • @Rees to be honest, I always have to check in http://stackoverflow.com/a/415444/1983854 to guess it. I would use `.bashrc`, but try and `.profile` should make it. And if you don't mind, come back and explain so we both learn it! – fedorqui Sep 12 '13 at 08:23