echo "example function"

If I use this in a shell script



I get command not found.

I have tried


source ~/.bashrc

but it doesn't work.

I found these answers and think this question deserves to live here with a clear question and clear and concise answer.

  1. Call a .bashrc function from a bash shell script
  2. How do you call a function defined in .bashrc from the shell?
  • When you said "but it doesn't work" can you explain? Does it give an error?
    – jesse_b
    Aug 25, 2020 at 23:45

1 Answer 1


Another thing to consider is that even if you run your program with #!/bin/bash, it will not execute .bashrc, as it is a non interactive instance of bash.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.