【问题标题】:Read variables from text file to shell script从文本文件中读取变量到 shell 脚本
【发布时间】:2014-03-29 16:18:52
【问题描述】:

我在同一目录中有一个脚本和一个包含此脚本变量的文件文本。 我需要阅读这些变量,但没有这个

. /path_to_my_file.file.txt

我不希望我的脚本中有任何路径。这样做不起作用

. file.txt

那么我还有什么其他的可能呢?

【问题讨论】:

  • 没有其他可能,可能
  • 是否可以使用 export 将路径定义为全局变量?
  • 您可以使用环境变量... export HERE=/users/fred/bloggs 然后在您的脚本中使用 ${HERE}。

标签: linux bash shell


【解决方案1】:

查看这个问题如何找出脚本在哪个文件夹中:Unix shell script find out which directory the script file resides?

之后,您可以使用此路径来获取“配置”文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-24
    • 1970-01-01
    • 1970-01-01
    • 2018-04-12
    相关资源
    最近更新 更多