0

I am not familiar with bash, but I would like to make an alias that deletes all files starting with a certain string. Here's what I have in my .bashrc:

alias myrm="rm $1*"

but that does not seem to work properly... What am I missing?

p-value
  • 608
  • 8
  • 22
  • 3
    Possible duplicate of [How to pass command line arguments to a shell alias?](https://stackoverflow.com/questions/941338/how-to-pass-command-line-arguments-to-a-shell-alias) – Benjamin W. Jan 23 '18 at 23:11

1 Answers1

1

Aliases can't use arguments. Use a function instead:

myrm() { rm "$1"*; }

Quoting Bash Reference Manual:

There is no mechanism for using arguments in the replacement text, as in csh. If arguments are needed, a shell function should be used.

PesaThe
  • 7,259
  • 1
  • 19
  • 43
  • 1
    @Hilbert It's most likely because the `alias` is still defined. Try to `unalias` it before `sourcing` the `.bashrc`. – PesaThe Jan 23 '18 at 23:17