Linked Questions

2
votes
1answer
847 views

Bash - shell vs environment variable [duplicate]

I want to clarify a confusion I am having in shell variable vs environment variable. I did the following test, where I have a shell variable abc and export it to an environment variable. $ $ abc="...
1
vote
1answer
239 views

HISTFILE env var unset within programs. Can I access it in any way? [duplicate]

When I try to access the "HISTFILE" env var within a program, it isn't there $ echo $HISTFILE /Users/drewgross/.bash_history $ python Python 2.7.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 ...
53
votes
9answers
25k views

How to print only defined variables (shell and/or environment variables) in bash

The bash builtin command set, if invoked without arguments, will print all shell and environment variables, but also all defined functions. This makes the output unusable for humans and difficult to ...
42
votes
2answers
53k views

What do the bash-builtins 'set' and 'export' do?

I am at a bit of a loss as to the purpose of set and export in Bash (and I guess probably other shells too). I would think it is for setting environment variables, but that can be done just with ...
15
votes
3answers
1k views

What is the difference in usage between shell variables and environment variables?

I actually did not know there are two different types of variables I can access from the command line. All I knew is, that I can declare variables like: foo="my dear friends" bar[0]="one" bar[1]="two"...
14
votes
3answers
19k views

What is the difference between env, setenv, export and when to use?

Recently I noticed we have 3 options to set environment variables: export envVar1=1 setenv envVar2=2 env envVAr3=3 If there are other ways, please enlighten us. When should I prefer one over the ...
4
votes
2answers
181 views

bash script: incorrect argument value being set

Problem I have a script that accepts a few different (optional) command line arguments. For one particular argument, I'm getting the value "less" appear but I don't know why. Bash Code while ...
3
votes
2answers
493 views

Am I using bash after this ordeal?

On Mountain Lion, host Coguaro, I login as user coconutpowder using bash: Coguaro:~ coconutpowder$ echo $0 -bash I need to run a command with elevated privileges so I try to su switch to root but it ...
3
votes
2answers
807 views

Convention personal environment variables

Is there an Unix convention for setting personal environment variables? I read they should be put in $HOME/.bash_profile instead of $HOME/.bashrc. Nonetheless, I was thinking of providing a way to ...
-4
votes
4answers
188 views

Is there a bash builtin command which can show the environment variables of the current shell?

env and printenv are both external commands i.e. executable files, not bash builtins. The problem with them is that some environment variables (such as _, and I also wonder if there are more) which ...
4
votes
2answers
92 views

Why does LC_MESSSAGES need to be exported on macOS homebrew bash to take effect?

On macOS, with bash installed from homebrew, I noticed that setting LC_MESSAGES seems to have some effect on the current shell's locale settings, but messages doesn't actually change until LC_MESSAGES ...