9

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?

4

1 回答 1

19

如果 filename 是x.txt,您可以使用命令替换将该文件的内容设置为环境变量。

export C=$(cat x.txt)
于 2013-07-30T17:01:55.177 回答