Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set environment variable from file contents?

On windows/cygwin, i want to be able save the PATH variable to file on one machine and load it onto the other machine;

for storing the variable i am doing:

echo %PATH% > dat

however, not sure how to load it later.

set PATH=???????

Thanks Rami

like image 958
sramij Avatar asked Jan 07 '12 03:01

sramij


People also ask

Can I use variables in .env file?

You can set default values for environment variables using a .env file, which Compose automatically looks for in project directory (parent folder of your Compose file). Values set in the shell environment override those set in the .env file.

How do I permanently set environment variables?

To make permanent changes to the environment variables for all new accounts, go to your /etc/skel files, such as . bashrc , and change the ones that are already there or enter the new ones. When you create new users, these /etc/skel files will be copied to the new user's home directory.


1 Answers

Just use: set /P PATH=< dat

You must note that echo %PATH% > dat insert an additional space after %PATH% value; that space may cause problems if an additional path is later added to PATH variable. Just eliminate the extra space this way: echo %PATH%> dat.

like image 52
Aacini Avatar answered Oct 23 '22 21:10

Aacini