I have been trying all day with no success to get bash to receive arguments: the closest reference to this I could find is:How to pass parameters to an alias? if i execute:rename -v -n 's/^the.//' * it does exactly what I need, but I would like to turn into into an alias that received the. string at run time. Is there a way of doing this?Please any ideas would be welcome!I have tried this, but with no success:alias rp=_rp(){ rename 's/$1//' *; unset -f _rp; }; _rp
bash alias rename function with arguments
bash;rename;alias;function
You can't use arguments in an alias. (You can append items after it, but that then just complicates this situation.) Here's what the man page (man bash) says about them:The first word of each simple command, if unquoted, is checked to see if it has an alias. If so, that word is replaced by the text of the alias. [...]There is no mechanism for using arguments in the replacement text. If arguments are needed, a shell function should be used. [...]For almost every purpose, aliases are superseded by shell functions.So, instead of an alias you should use a function.rp() { rename s{$1}{} *; }    # No {} characters in the substitutionUsagerp 'the.'    # Quotes optional but recommended. Remember . represents any character