Reputation: 21553
I am trying to make it easier to use scp so I learned about alias today, and I am using it like this:
alias loudie-scp="scp -i keys/aws.pem $1 [email protected]:/home/ec2-user"
the $1 is there to specify the file i want to transfer over. However this is not working and giving me an error:
scp: /home/ec2-user: not a regular file
This does not happen when I execute this command manually passing in any file for $1.
Upvotes: 1
Views: 527
Reputation: 56059
As I'm sure Ignacio's link will explain, an alias does nothing more than textually expand the alias to its value. It does not take arguments, you need to use a function for that.
Upvotes: 0
Reputation: 8937
Unfortunately BASH aliases are kind of like find-and-replace -- they're not very powerful for the sort of task you describe. I would suggest using, instead, a script file and placing it in an executable directory; something like so:
#!/bin/bash
scp -i keys/aws.pem $1 [email protected]:/home/ec2-user
Then, given that it has the name loudie-scp
you could call it like so:
loudie-scp <parameter>
Upvotes: 0
Reputation: 798566
BASH FAQ entry #80: "How can I make an alias that takes an argument?"
Upvotes: 4