Results 1 to 6 of 6
Hello
This is probably a very easy thing to do, but I don't know how: I'd like to export an env't variable, and then use its reference in a Bash ...
- 07-06-2010 #1Linux Newbie
- Join Date
- Nov 2007
- Posts
- 127
[newbie] Dereferencing exported variable?
Hello
This is probably a very easy thing to do, but I don't know how: I'd like to export an env't variable, and then use its reference in a Bash script
FWIW, the script is running on Ubuntu 10.04.Code:# export MYDIR=/tmp # echo $MYDIR /tmp # find $(MYDIR)/user/lua/ -type f -name auxiliar.h MYDIR: command not found find: `/user/lua/': No such file or directory
Thank you for any help.
- 07-06-2010 #2Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
Use curly braces - {} - not parentheses - () ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 07-07-2010 #3
drl is 100% correct.
To be a bit more specific, ${foo} prints out the value of the foo variable. $(foo) runs the command "foo" and is replaced with its output.
In your particular case, you can just say $MYDIR/usr/lua, because '/' cannot be part of a variable name, so Bash knows that the name of the variable is just MYDIR.DISTRO=Arch
Registered Linux User #388732
- 07-07-2010 #4Linux Newbie
- Join Date
- Nov 2007
- Posts
- 127
Thanks for the tip. I saw this command in a Makefile and was wondering why it didn't work when I typed it at a Bash prompt.
- 07-08-2010 #5
Ah, well, in Makefiles, $(var) is the command for a variable
. Makefile scripting isn't the same as Bash scripting.
DISTRO=Arch
Registered Linux User #388732
- 07-08-2010 #6Linux Newbie
- Join Date
- Nov 2007
- Posts
- 127
Yup, that's what it looks like


Reply With Quote