Results 1 to 4 of 4
Hello. I'm playing around with some shell scripting and I've got a directory call CS005 and I'm trying to write a script to I can locate to the directory really ...
- 01-26-2011 #1Just Joined!
- Join Date
- Jan 2008
- Posts
- 13
Allowing export to take numbers as variables
Hello. I'm playing around with some shell scripting and I've got a directory call CS005 and I'm trying to write a script to I can locate to the directory really quick and easy.
export CS005DIR=/home/stud/0/043234/CS005
Now I get this error
CS005DIR=/home/stud/0/043234/CS005 No such file or directory.
This is because I've got numerical values within my variable.
Is there a way to allow numbers for variable names?
Thanks
- 01-26-2011 #2Just Joined!
- Join Date
- Mar 2007
- Location
- Bogotá, Colombia
- Posts
- 39
It shouldn't be a problem, try to enclose the path in quotes
try this yourself:
CS005DIR="/home/stud/0/043234/CS005" ; echo $CS005DIR
bash should echo your path
- 01-26-2011 #3Just Joined!
- Join Date
- Jan 2008
- Posts
- 13
- 01-27-2011 #4Just Joined!
- Join Date
- Mar 2007
- Location
- Bogotá, Colombia
- Posts
- 39
You can use a little trick to make bash accept your variable name, start it with an underscore:
_2CS005DIR="/your/path" ; echo $_2CS005DIR
that should work.


Reply With Quote
