How to call .bashrc function in script

Unix & Linux Asked by young_souvlaki on September 14, 2020

    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?

One Answer

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.

Answered by user429927 on September 14, 2020

Add your own answers!

Related Questions

Samba share permission denied user writing file but still shows

1  Asked on January 6, 2022 by shrimpwagon


QEMU – network bridge

2  Asked on January 6, 2022 by matthew-lugg


What happens when you run out of PIDs?

3  Asked on January 5, 2022 by fpf3


Encrypting archive and then dividing it into many parts

2  Asked on January 5, 2022 by user216488


Monitoring CPU and temperature

5  Asked on January 5, 2022 by zeno-raiser


cURL url_effective with Hash

2  Asked on January 5, 2022 by zombo


How to delete files using grep?

1  Asked on January 5, 2022


sudo twice become method for Ansible

0  Asked on January 5, 2022


dotnet –help -> Segmentation fault (core dumped)

1  Asked on January 5, 2022 by szoke-lorand


Create DNS query with Netcat or /dev/udp/

1  Asked on January 3, 2022 by user424280


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP