user1427429 user1427429 - 1 year ago 61
Bash Question

Setting an environment variable in Cygwin

I have been trying to setup a environment variable in Cygwin using the command

export PRIMOSBASE=/directory/for/primosfiles

And when i check the variable using the command
it shows the /directory/for/primosfiles. hopeful this means the environment variable is set.

But when i try to run a shell script(primos) for the /directory/for/primosfiles, it shows

./primos: line 8: / No such file or directory
chmod: failed to get attributes of `': No such file or directory

which means i have not set the PRIMOSBASE environment. could anyone please tell me where i am going wrong...

Thanks ...



echo "export PRIMOSBASE=/directory/for/primosfiles" >> ~/.bashrc

to append the command to the end of your .bashrc file, so that the variable is set each time you use Cygwin. Then run

source ~/.bashrc

to make it take effect immediately.

NOTE: Make sure you use double brackets (>>) to append. It might be a good idea to make a backup of .bashrc just in case. If you're not comfortable with I/O redirection, an alternative is to edit .bashrc with an editor. I think vim is among the default tools in Cygwin.