when you create the alias, the shell substitutes the $1
(to nothing, probably) since your alias is in ""
(double quotes).
now, if you swap the single and double quotes, then the substitution still happens, but at invocation time instead of at definition time.
you actually want perl to deal with this $1
, so neither is good.
you have three options:
- write a function instead, as has been suggested
- use
''
quoting, which lets you put ’ (single quote) inside ’ (single quote) without going mad:alias cica=$'foo \'$bar\' baz'
- go insane and do this:
alias cica='foo '\''$bar'\'' baz'
(this is the old way, without bash’s''
)
i’d probably do
function cap() { prename 's/(^[a-z]?)/\U$1/' "$@" }
it means it has to be invoked as
cap *
, but it also means that you can docap foo*
or whatever