Edit shell function
Hi guys,
I am Juanelo. Glad to be here and try to learn and share about Linux. This is my first question, so maybe it's a very easy one. Please be kind with me xD I got a VM with CentOS on it which has already some shell functions precharged on them, e.g. function1. I want to modify one of this functions because I need to add some environmental variables to it but I simply cannot find its location. If I type "type function1" the shell shows me it is actually a function and I can see its definition so I guess it should be stored somewhere in the system. I tried to locate it by examining the directories defined in $PATH but unfortunately I cannot find it anywhere. I guess the easiest way would be to copy all the definition into a new file, add the required variables and then copy it within one of the directories set on $PATH, but I would like to learn how to locate and edit it, in case it is hidden or something. I would really appreciate any explanation on this and any help. Thank you! |
hey welcome...im a real newb but i will try and help
i dont think functions are actually files in the file system i think they are defined in scripts that are hidden in your home directory and in /etc i think it has something to do with these scripts depending on what distro/version you using centos6 or 7? /etc/bashrc ~.bashrc i might be completely wrong...but we have the ball rolling now we will see what some of the geniuses say next. |
As sigint-ninja said, functions are not programs. They do not have their own executables and you will not find them anywhere on your filesystem, $PATH or otherwise. Functions are defined "on-the-fly" in the shell initialization scripts. For example, buried in your .bashrc, you might find:
Code:
function i () { You didn't mention which shell you're using, each shell uses its own initialization script, eg: ~/.bashrc, ~/.cshrc, ~/.zshrc, and so on. There are also the system-wide initialization scripts in /etc. Code:
ls ~/.*rc |
Hi!
I checked the .bashrc and the .bash_profile scripts but i cannot find the function there, which other scripts/files should I check additionally? |
Sorry, short reply. I am using CentOS 6 and don't know which bash I am using. I do have the script ~/.bashrc. Is that enough or how I can check which bash I am using?
|
echo $0
bash --version |
Quote:
|
Thank you suicidalegroll! I finally found it using the ls ~/.*rc command. It was located in the root/.bashrc script. I sincerely appreciate your help guys.
Have a nice day :) |
All times are GMT -5. The time now is 03:05 AM. |