shell脚本读取配置文件
2012-07-12 14:56
453 查看
我现在有个配置文件config,里面内容为
ID=123
IP=192.168.3.154
Name=test
想写个shell脚本,把这几个变量的值给读出来
高手指点下
Answer:
[root@RHEL6A shcode]# more config
ID=123
IP=192.168.3.154
Name=test
[root@RHEL6A shcode]# echo $ID
0
[root@RHEL6A shcode]# more sh13.sh
#!/bin/bash
source config
echo $ID
echo $IP
echo $Name
[root@RHEL6A shcode]# ./sh13.sh
123
192.168.3.154
Name
提供3种方法
while read -r line
do
eval "$line"
done < configfile
echo $ID
#id=`sed '/^ID=/!d;s/.*=//' configfile`
#echo $id
source configfile
echo $ID
ID=123
IP=192.168.3.154
Name=test
想写个shell脚本,把这几个变量的值给读出来
高手指点下
Answer:
[root@RHEL6A shcode]# more config
ID=123
IP=192.168.3.154
Name=test
[root@RHEL6A shcode]# echo $ID
0
[root@RHEL6A shcode]# more sh13.sh
#!/bin/bash
source config
echo $ID
echo $IP
echo $Name
[root@RHEL6A shcode]# ./sh13.sh
123
192.168.3.154
Name
提供3种方法
while read -r line
do
eval "$line"
done < configfile
echo $ID
#id=`sed '/^ID=/!d;s/.*=//' configfile`
#echo $id
source configfile
echo $ID
相关文章推荐
- shell脚本读取ini配置文件的值
- 读取配置文件的shell脚本实现
- shell脚本按行读取配置文件并解析
- shell脚本读取ini配置文件的值
- shell脚本读取ini配置文件的值
- 如何用shell脚本读取配置文件
- shell脚本读取ini配置文件的值
- shell脚本读取配置文件
- shell脚本读取ini配置文件的值
- shell脚本读取配置文件
- Shell脚本读取ini配置文件的实现代码2例
- Shell脚本读取ini配置文件的实现代码2例
- shell脚本获取配置文件中的内容
- shell脚本获取配置文件中的内容
- Shell实现读取ini格式配置文件方法
- shell 读取配置文件
- 一个读取文件内容的shell脚本
- shell脚本:一次读取文件的一行,并输出
- shell脚本修改配置文件中的内容
- shell脚本按行读取文件并解析