I know that, Shell variables are not available to the parent or child shells and Shell environments are available for child shells.
When I want to permanently add current directory to PATH I can do it in 2 ways:
1-Normal way:
[sinoosh@localhost ~]$ vi ~/.bash_profile
2-without export command
And then logout i see the same result as normal way
there is not different between "1"&"2" . can we say the export
command is useful for that time we do not want permanently add to environment variables?
What's happening here?
The
export
(ordeclare -x
) declaration makes the difference between a plain shell variable and an environment variable.Since
PATH
is almost certainly already part of your environment - having been set in/etc/environment
for example - marking it for export a second time isn't strictly necessary[1] (although it does no harm - and make the intent clear).1 at least I think that's the case - I'd like to find a primary reference