I want to make an alias for randomly changing my mac address
alias chrandmac="sudo ifconfig en0 ether $(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')"
but the command substitution part is already resolved when executing the profile.
alias chrandmac='sudo ifconfig en0 ether 83:3a:bf:fc:4e:29'
Any thoughts as to why this occurs?
$(....)
part is done when the alias is defined, not when it runs. Use a shell function. – vonbrand Mar 30 '13 at 22:54$()
happens inside of double quotes. That can be avoided. – jordanm Mar 31 '13 at 00:58