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?
Advertisement
Answer
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)