shell 读取配置文件的方法
原文地址:http://bbs.chinaunix.net/thread-3628456-1-1.html
总结地址:https://www.cnblogs.com/binbinjx/p/5680214.html
配置文件config内容如下
- ID=
- IP=192.168.3.154
- Name=test
方法一,利用sed解析文本,提取配置信息
- id=`sed '/^ID=/!d;s/.*=//' urfile`
- ip=`sed '/^IP=/!d;s/.*=//' urfile`
- name=`sed '/^Name=/!d;s/.*=//' urfile`
- echo $id
- echo $ip
- echo $name
方法二,利用eval方法解析
- while read line;do
- eval "$line"
- done < config
- echo $ID
- echo $IP
- echo $Name
方法三,直接将配置信息加载到session的环境变量中
- source config
- echo $ID
- echo $IP
- 192.168.3.154
- echo $Name
- test
shell 读取配置文件的方法的更多相关文章
- Shell读取配置文件的方法
参考:http://www.cnblogs.com/binbinjx/p/5680214.html 做批量软件安装自动化时,都喜欢用配置文件的方式改变参数,那怎么通过shell读取配置文件的配置呢?参 ...
- Log4j 2.0读取配置文件的方法
log4j中配置日志文件存放的位置不一定在src下面,即根目录下.这个时候我们需要解决如何加载配置文件的问题.在log4j1.x中解决的方法就比较多了.如:PropertyConfigurator.c ...
- 面试突击75:SpringBoot 有几种读取配置文件的方法?
Spring Boot 中读取配置文件有以下 5 种方法: 使用 @Value 读取配置文件. 使用 @ConfigurationProperties 读取配置文件. 使用 Environment 读 ...
- java中读取配置文件的方法
转自:http://blog.csdn.net/stypace/article/details/38414871 一.使用org.apache.commons.configuration 需要使用的是 ...
- linux shell读取配置文件
配置文件CoverageInfo FTP_URL=ftp://svn-fb.sicent.com:21/jenkins/Jifei_Repo/OL-2/IDC_Platform/bar_seats_c ...
- Spring ClassPathXmlApplicationContext和FileSystemXmlApplicationContext读取配置文件的方法
先说:ClassPathXmlApplicationContext 这个类,默认获取的是WEB-INF/classes/下的路径,也就是在myeclipse的src下的路径,所以用这个是获取不到WEB ...
- ASP .NET CORE 读取配置文件的方法
老式的config文件在ASP.net core2.0中变成了appsettings.json,如果想要读取自定义配置,可以写如下代码 { "Logging": { "I ...
- java读取配置文件的方法
1. Preferences类 这个主要是设置个人喜好.它的数据一般存在系统目录或是用户目录.还可以操作注册表. 2. Properties类 保存键值对.可以指定路径. 3. commons con ...
- shell 读取配置文件的用法
https://blog.csdn.net/qq_36684665/article/details/81134179 亲测有用!
随机推荐
- sqlServer 获取最新的一条数据
SQL语句获取最新一条的数据 * from tra.dbo.订单 order by 下单时间 desc --时间倒序排列取第一条 select * from tra.dbo.订单 where 下单时间 ...
- Python输出和输入
一.input()函数 在 Python 中,使用内置函数 input()可以接收用户的键盘输入. input()函数的基本用法如 下: variable = input("提示文字") 其中,var ...
- MySQL服务使用
MySQL服务使用 1. 启动服务 启动服务: service mysql start 或者 sudo /etc/init.d/mysql start 2. 关闭服务 关闭服务: service my ...
- 从零开始的cve分析- cve-2016-0095 简易记录
0x00 前言 看k0shl大佬的SSCTF pwn450 Windows Kernel Exploitation Writeup一文,试着写一个x64下的poc. poc地址:https://git ...
- C# -- 随机数产生的字母金字塔
C# -- 随机数产生的字母金字塔 1. 代码实现: static void Main(string[] args) { showNpoint(); Console.ReadKey(); } priv ...
- June 4. 2018 Week 23rd Monday
Don't criticize what you can't understand. 不懂的,不要随意批判. From Bob Dylan. Don't criticize what you can' ...
- C# → 数据库
Database: public static class dbconnection{ static string cons = "data source = (local) ;initia ...
- nodejs websocket
<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script> <script ty ...
- E. Magic Stones CF 思维题
E. Magic Stones time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- 「AHOI / HNOI2017」单旋
「AHOI / HNOI2017」单旋 题目链接 H 国是一个热爱写代码的国家,那里的人们很小去学校学习写各种各样的数据结构.伸展树(splay)是一种数据结构,因为代码好写,功能多,效率高,掌握这种 ...