I am working on linux and I want to set an environmental variable to the contents of a file: vi file:
the env var should equal everything in here
Now the file has a lot of " and other special characters and it will a take a lot of time to escape them all. Is there an easier way?
If filename is x. txt , you can use command substitution to set the content of that file as an environment variable. Please explain why this would work instead of just giving an answer. A more recent syntax is export C=$(cat x.
You can put environment variables in your properties file, but Java will not automatically recognise them as environment variables and therefore will not resolve them. In order to do this you will have to parse the values and resolve any environment variables you find.
The command env displays all environment variables and their values.
If filename is x.txt
, you can use command substitution to set the content of that file as an environment variable.
export C=$(cat x.txt)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With