bash built in function bash source code bash built in function bash source code shell shell

bash built in function bash source code


You can do it like this:

# Turn on debug$ shopt -s extdebug# Print out the function's name, line number and file where it was sourced from$ declare -F my_functionmy_function 46 /home/dogbane/.bash/.bash_functions# Turn off debugshopt -u extdebug

To edit the function, open the file containing the function definition (that you found from above). Edit the function and save the file. Then source it into your shell, like this:

$ . /path/to/function_file


Functions are typically stored in the .bashrc file (or in /etc/bash.bashrc, which also exists as just /etc/bashrc on some systems). This answer from SuperUser has some good details on what a .bashrc file is. Similarly, this question on the Unix & Linux site details when it's best to alias, when to script, and when to write a function.