In order to speed up typing of a long command, we can make an alias of a command, e.g.
alias remcopy='scp [email protected]:/home/file.txt /home/user/'
And we type user
this exact command will be run.
However, is it possible only to load the command and then modify it according to the current need, e.g.
scp [email protected]:/home/file.txt /home/user/addeddir/
There are two ways you can start various modifications of the command.
an alias can have a parameter, for example
where
targetname
is selected a run time.a function is more flexible than an alias. It can be a single line or big like a whole shellscript file.
which can be used without a parameter and with a parameter (in order to change the name of the target file.
You can store a small function in
~/.bashrc
like you store aliases.You can use variables to accomplish this.
For example:
Will open test.txt in nano for writing