I have a file say my-file.dat
which has multiple lines. I want to set an env variable say MYVAR
that will contain the content of my-file.dat.
That is, in windows command prompt, the output of type my-file.dat
be same as the output of echo %MYVAR%
and with new-line preserved.
In RHEL/MAC, it is typically done like this export MYVAR=$(cat my-file.dat)
, but how do I do the similar in windows command prompt (not really interested in powershell, but feel free to share examples it might be my backup option)
Following the answer of this Stackoverflow question Multiline text file, how to put into an environment variable I could get a variable to hold the content of my-file.dat. But this variable's scope seems to be the batch file. Even though I run the batch file from the command prompt, I don't see the batch-file's variable is available in the command prompt.
I tried set /P MYVAR=<my-file.dat
, but this sets only the first line whereas I want all lines when I echo MYVAR
Pls help.