linuxbashscp

Shortcut command creation for scp linux command


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 abc@example.com:~/

the destination (abc@example.com) 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 abc@example.com:~/) without typing the destination location

note: (abc@example.com in this case might seem short however i have a much more complex destination that is cumbersome to type out every single time)


Solution

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

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

    And thus you invoke it as follows:

    do-scp 123.txt