All Questions
12
questions
0
votes
2
answers
124
views
Export directory in `bashrc` without having to quote the variable
Currently in my bashrc I export a variable export dl="path/to/Downloads". The path contains a space in it so whenever I mv something from the directory, I have to quote the dl variable such ...
5
votes
2
answers
22k
views
Environment Variables with $ Character [duplicate]
I'm using a MacOS. I tried to enter this environment variable inside my .bash_profile:
export CLOUD_PASSWORD=Pass4Aa$ditya
But when I do source .bash_profile and try echo $CLOUD_PASSWORD, I get this ...
0
votes
3
answers
2k
views
Which quoting style GNU Bash variable definitions (mostly for paths)? [closed]
Which of the following quoting styles, for GNU Bash variables, is preferred and why?
Two double quotes: VAR="/path/$V1/path with space/$V2".
Multiple double quotes: VAR=/path/"$V1"/"path with space"/"...
1
vote
2
answers
6k
views
Why is this environment variable not set up?
When a shell runs an external executable as a command, we can pass
environment variables into the executable.
$ var=3 /bin/echo `$var`
$ var=3 bash -c "/bin/echo '$var'"
both don't output anything.
...
4
votes
2
answers
3k
views
Why some commands don't load user environment when executed with ssh? (while other do)
On a target machine (OS X El Capitan) I have brew in /usr/local/bin. When I try to get brew's path I get no result:
# ssh [email protected] -p 2222 which brew
#
Troubleshooting:
brew is in /usr/...
6
votes
6
answers
14k
views
How to pass an environment variable when change rooting?
I don't seem to be able to pass an environment variable to a chroot:
$ sudo apt-get install debootstrap dchroot
$ sudo debootstrap trusty mychroot
$ sudo chroot mychroot /bin/bash -c "MY_VAR=5; echo $...
2
votes
2
answers
734
views
Meaning of \ before environment variable
In ksh on an old Solaris box I used:
export PS1="$PWD $"
to set the prompt to the current directory. It works great until you cd elsewhere, then you see that it's not evaluating PWD each time. I ...
4
votes
6
answers
25k
views
How do I pass a variable from my local server to a remote server?
I am trying to pass a variable from my local server (location1) to a remote server (location2). The purpose of the code is to copy a file from the remote server from a predefined location. In simpler ...
25
votes
2
answers
12k
views
Expansion of a shell variable and effect of glob and split on it
This post actually contains two separate questions but I think grouping them together will give some more context. I have gone through this question on quotes around variables but I do not quite ...
2
votes
1
answer
5k
views
bash: export: `--wait': not a valid identifier
When I run git-sh from my terminal it works fine. But I get the following warning.
bash: export: `--wait': not a valid identifier
What is this and how do I get rid of it?
38
votes
2
answers
51k
views
What is the significance of single and double quotes in environment variables?
I defined some environment variables in my .profile like this:
MY_HOME="/home/my_user"
but the variable does not seem to evaluate unless I strip off the quotes and re-source the file. I believe the ...
217
votes
3
answers
105k
views
$VAR vs ${VAR} and to quote or not to quote
I can write
VAR=$VAR1
VAR=${VAR1}
VAR="$VAR1"
VAR="${VAR1}"
the end result to me all seems about the same. Why should I write one or the other? are any of these not portable/POSIX?