初学shell,读取environment-variable-mac.ini文件中变量,写入到一个js格式的文件内

environment-variable-mac.ini文件

UNIVER_USER_LOGIN='http://127.0.0.1/api/login'
UNIVER_SEARCH_ORDINARY='http://127.0.0.1/api/search/common'
UNIVER_SEARCH_LABEL='http://127.0.0.1/api/search/common'
UNIVER_SEARCH_VIDEO='http://127.0.0.1/api/search/common'
UNIVER_TASK_MANAGER='http://127.0.0.1/api/task/manager'
UNIVER_PROJECR_URL='67.110.220.11'
UNIVER_PROJECR_PORT=777778888

怎么才能实现?

阅读 373
评论 2018-08-14 提问
    1 个回答
    ezmo
    • 6.9k

    使用awk命令即可

    awk -F '=' 'BEGIN {print "{"} {print "\t"$1":"$2","} END{print "}"}' environment-variable-mac.ini > environment-variable-mac.json
    评论 赞赏 2018-08-15
      撰写回答

      登录后参与交流、获取后续更新提醒