This example of the book needs to be supported in Ubuntu's lower version of the system, and now basically does not support, want to implement it is very simple to write a script to back up and then delete.
Alias has just made a replacement.
Alias rm= ' CP [email protected] ~/backup; RM [email protected] '
RM text.txt
was converted into a
CP [email protected] ~/backup; RM [email protected] text.txt that
CP ~/backup; RM text.txt
You can see that text.txt has been removed.
This does not work, and the first statement cannot get the arguments. I don't know why I can't do this. But I can give you an alternative, which is to define a function that takes arguments as arguments to the function:
Alias saferm= ' Saferm () {CP [email protected] ~/backup; RM [email protected];}; saferm [email protected] ' saferm abc.txt
So you can write as many commands as you like.
However, if the command is complicated, it is recommended to write the shell script
#!/bin/bash
#/home/yourname/saferm
CP [email protected] ~/backup RM [email protected]
Then create an alias
chmod +x/home/yourname/saferm
Alias Saferm=/home/yourname/saferm
can also be placed directly under the system path ~
About Linux shell programming, alias Rm= ' CP [email protected] ~/backup; RM [email protected]'