Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个看起来像这样的输入文件:
VAR1=1 VAR2=2 VAR3=3 VAR4=.T.
我想读入这些变量并这样定义它们。我试过了
while read line do exec $line done < "Master.inp"
我试过了
$line
相反,但这也不起作用。有没有办法像我刚刚在 bash 文件中键入字符串一样运行字符串?
您只需获取代码即可:
. file
这将让您使用 vars $VAR1, $VAR2, ...
$VAR1
$VAR2
$ cat a VAR1=1 VAR2=2 VAR3=3 VAR4=.T. $ cat b . a echo $VAR1 $ ./b 1