0

I am using secure copy to copy some data from a server to a folder (let's say: scp [email protected]:/project1/data/ data1/).

My question is if it is possible to save the address of the server (in the example [email protected]:/project1/) to a shorter form, like an alias, and use it instead of the full name. For example, I'd like to save the address as "prj1" and use the command scp prj1/data data1/ to make the same thing.

Unfortunately, alias, and ls -s don't work.

Is it possible?

Thanks

1 Answer 1

1

Have you considered a variable?

prj1='[email protected]:/project1'    # Define variable
scp -p "$prj1/data/" data1/         # Use it

Or you could use a function

prj1scp() { scp -p "[email protected]:/project1/$1" "$2"; }
prj1scp data ~/data1/               # Invoke the function

One of the reasons that using a function is more powerful than a simple alias is that you can make it as complex as you need. It can have parameters that affect how it executes, or you can substitute in parameters you provide on the command line.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .