Reputation: 367
Hi i want to run a linux command that automates a scp with the location of origin that varies and the destination location that remains contant. For example -
scp 123.txt [email protected]:~/
the destination ([email protected]) will always be the same, however the file name (123.txt) will always be different.
I would like to run this entire scp command (scp 123.txt [email protected]:~/) without typing the destination location
note: ([email protected] in this case might seem short however i have a much more complex destination that is cumbersome to type out every single time)
Upvotes: 4
Views: 2480
Reputation: 41
In case you would like to use the shortcut with a slightly different destination on the remote location called 'xyz', you could add in your ~/.bashrc:
function scp_xyz() { scp $1 [email protected]:"${2}" }
And then use:
scp_xyz 123.txt /different_destination_on_xyz/
Upvotes: 1
Reputation:
You can define a function in bash, for example:
my_scp()
{
scp $1 [email protected]:~/
}
and use
$my_scp 123.txt
You can put them in ~/.bash_profile so that they are always available
Upvotes: 0
Reputation: 12534
Try using a function instead of an alias. Put the following function in your .bashrc file.
function do-scp() {
scp "$1" [email protected]:~/
}
And thus you invoke it as follows:
do-scp 123.txt
Upvotes: 12