Create command shortcut to scp linux command

Hi I want to run a linux command that automates scp with origin location that changes and destination that remains the same. For example -

scp 123.txt abc@example.com:~/

      

the destination ( abc@example.com ) will always be the same, however the filename (123.txt) will always be different.

I would like to run this whole scp command (scp 123.txt abc@example.com : ~ /) without entering the destination

Note: ( abc@example.com may seem short in this case, however I have a much more complicated assignment that is cumbersome to type every time)

+3


source to share


2 answers


Try using a function instead of an alias. Place the following function in your .bashrc file.

function do-scp() {
    scp "$1" abc@example.com:~/
}

      



And this way you call it like this:

do-scp 123.txt

      

+7


source


You can define a function in bash, for example:

my_scp()
{
  scp $1 abc@example.com:~/
}

      

and use



$my_scp 123.txt

      

You can put them in ~ / .bash_profile so that they are always available

0


source







All Articles