How do you call a function defined in .bashrc from the shell?

后端 未结 6 1460
醉梦人生
醉梦人生 2021-01-30 19:30

In my .bashrc, I have a function called hello:

function hello() {
   echo \"Hello, $1!\"
}

I want to be able to invoke hello() from the shell a

6条回答
  •  野性不改
    2021-01-30 20:29

    Any changes made to .bashrc will only take effect in a new terminal session. If you want to apply the changes to your current terminal session, you have to instruct the shell to re-read the .bashrc. The shortest way to to this is to use the . command, which is a synonym to source:

    [user@linuxPc]$ . ~/.bashrc
    

提交回复
热议问题