i tried to use the Linux alias:
rm='cp $* ~/dustbin; rm $*'
but it reported 'missing destination file operand after ~/dustbin' , why didn't cp recognize ~/dustbin as destination ?
i tried to use the Linux alias:
rm='cp $* ~/dustbin; rm $*'
but it reported 'missing destination file operand after ~/dustbin' , why didn't cp recognize ~/dustbin as destination ?
Do you use bash? man bash:
There is no mechanism for using arguments in the replacement text. If
arguments are needed, a shell function should be used (see FUNCTIONS
below).
Use function, e.g.:
rm() { cp $* ~/dustbin; /bin/rm $*; }
alias rm='echo $*' does print out the arguments, why didn't cp receive the arguments ?
– yang frank
Nov 23 '15 at 03:59
$* of alias does not receive arguments and seems to disappear. So, alias rm='echo $*' is equal to alias rm=echo, and rm a b c is echo a b c.
– masm
Nov 23 '15 at 05:00