注: 部分概念介绍来源于网络
配置文件内容如下config.properties:
name=li
age=20
shell脚本内容如下:
current_path=$(cd `dirname $0`;pwd)
echo $current_path
source $current_path/config.properties
echo $name
echo $age
本文介绍了一个简单的Shell脚本案例,该脚本用于加载并读取配置文件的内容。通过使用`source`命令,脚本能够获取配置文件中的变量,并将其值输出到标准输出。此方法适用于各种需要从配置文件中读取参数的场景。
注: 部分概念介绍来源于网络
配置文件内容如下config.properties:
name=li
age=20
shell脚本内容如下:
current_path=$(cd `dirname $0`;pwd)
echo $current_path
source $current_path/config.properties
echo $name
echo $age
3805
862
1943

被折叠的 条评论
为什么被折叠?