Form the unset entry in the bash manpage: If -f is specified, each name refers to a shell function, and the function definition is removed. Note: -f is only really necessary if a variable with the same name exists. If you do not also have a variable named foo , then unset foo will delete the function.
To remove the definition of a function from the shell, use the unset command with the . f option. This command is also used to remove the definition of a variable to the shell.
Remove Character from String Using trThe tr command (short for translate) is used to translate, squeeze, and delete characters from a string. You can also use tr to remove characters from a string. For demonstration purposes, we will use a sample string and then pipe it to the tr command.
unset -f z
Will unset the function named z. A couple people have answered with:
unset z
but if you have a function and a variable named z only the variable will be unset, not the function.
In Zsh:
unfunction z
That's another (arguably better) name for unhash -f z
or unset -f z
and is consistent with the rest of the family of:
unset
unhash
unalias
unlimit
unsetopt
When in doubt with such things, type un<tab>
to see the complete list.
(Slightly related: It's also nice to have functions/aliases like realiases
, refunctions
, resetopts
, reenv
, etc to "re-source
" respective files, if you've separated/grouped them as such.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With