Make a Bash alias that takes a parameter?

后端 未结 20 2006
长发绾君心
长发绾君心 2020-11-21 06:53

I used to use CShell (csh), which lets you make an alias that takes a parameter. The notation was something like

alias junk=\"mv \\\\!* ~/.Trash\"

20条回答
  •  走了就别回头了
    2020-11-21 07:14

    As has already been pointed out by others, using a function should be considered best practice.

    However, here is another approach, leveraging xargs:

    alias junk="xargs -I "{}" -- mv "{}" "~/.Trash" <<< "
    

    Note that this has side effects regarding redirection of streams.

提交回复
热议问题