BASH解析从配置文件中的变量 [英] BASH Parsing variables from config file

查看:125
本文介绍了BASH解析从配置文件中的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具有在一个文件中的以下内容:

Having the following content in a file :

VARIABLE1="Value1"
VARIABLE2="Value2"
VARIABLE3="Value3"

我需要一个脚本,输出如下:

I need a script that outputs the following :

Content of VARIABLE1 is Value1
Content of VARIABLE2 is Value2
Content of VARIABLE3 is Value3

任何想法?

推荐答案

的awk -F \\ ={GSUB(//,,$ 2);打印$ 1的内容是$ 2}'<&名GT;

仅供参考,另一个纯bash的解决方案

Just FYI, another pure bash solution

IFS="="
while read -r name value
do
echo "Content of $name is ${value//\"/}"
done < filename

这篇关于BASH解析从配置文件中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆