Unable to unbind a shell function

2019-03-06 06:41发布

问题:

This question is based on the thread.

I have the shell function

function man()
{       
    man "$1" > /tmp/manual; less /tmp/manual 
}

The problem is there exists the command man.

How can you replace the command with my command?

回答1:

Replace man "$1" with the pathname: /usr/bin/man. Or change it to use 'which man' within backquotes. Then run your script in the current shell. On bash/ksh you need to save your script in some file, say man.sh and then run it as '. ./man.sh'.

cat > man.sh
function man()
{       
    /usr/bin/man "$1" > /tmp/manual; less /tmp/manual 
}
^D

. ./man.sh

You get the idea. You can undefine the function at any time: unset -f man



标签: less man