LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Where all these variables stored? (https://www.linuxquestions.org/questions/linux-newbie-8/where-all-these-variables-stored-4175468965/)

v3ct0r 07-09-2013 02:41 AM

Where all these variables stored?
 
I type in "set" and "env" command and find those variables but they are not setted in ~/.bash_profile so I suppose those things was configed in somewhere in /etc/.
Am I right?
I am new to bash.

druuna 07-09-2013 02:47 AM

There are more places bash looks when you start a bash shell.

- Execution sequence for .bash_profile, .bashrc, .bash_login, .profile and .bash_logout

Also have a look at the INVOCATION section in the bash manual page (man bash). Here's a summary: Bash Startup Files

v3ct0r 07-09-2013 03:09 AM

re:drunna
 
Quote:

Originally Posted by druuna (Post 4986773)
There are more places bash looks when you start a bash shell.

- Execution sequence for .bash_profile, .bashrc, .bash_login, .profile and .bash_logout

Also have a look at the INVOCATION section in the bash manual page (man bash). Here's a summary: Bash Startup Files


Code:

if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
My .bash_profile simply contains this line, what does the "-f" and "." after then means?

Madhu Desai 07-09-2013 03:19 AM

Quote:

Originally Posted by xeechou (Post 4986781)
Code:

if [ -f ~/.bashrc ]; then . ~/.bashrc; fi

It means if there is a file called .bashrc in user's home folder, then source it.

source it - means run commands in that script, but instead creating a new subshell, execute them in present shell. so whatever you have set in script are now available to current shell (something like logout-login or refresh).

-f = if file exists
. = sourcing (you can also use 'source' instead of '.' both are same)

v3ct0r 07-09-2013 04:02 AM

Quote:

Originally Posted by mddesai (Post 4986785)
It means if there is a file called .bashrc in user's home folder, then source it.

source it - means run commands in that script, but instead creating a new subshell, execute them in present shell. so whatever you have set in script are now available to current shell (something like logout-login or refresh).

-f = if file exists
. = sourcing (you can also use 'source' instead of '.' both are same)


It looks that there are lots of parameters can be list in [conditions], like -f -z -n, does all these are parameters from command "test"?



druuna 07-09-2013 04:09 AM

Quote:

Originally Posted by xeechou (Post 4986798)
It looks that there are lots of parameters can be list in [conditions], like -f -z -n, does all these are parameters from command "test"?

The test man page does tell you what these options do. They are also explained in the bash manual page (CONDITIONAL EXPRESSIONS section).


All times are GMT -5. The time now is 09:57 AM.