Linux shell 自动化配置icp-slam ini文件 rawlog文件 log文件位置

本文介绍了如何使用shell脚本来自动化配置icp-slam的ini文件、rawlog文件以及log文件的位置,包括dealIni.sh和icp-slam.sh两个脚本的使用方法和源码展示。
摘要由CSDN通过智能技术生成

1.功能:shell 自动化配置icp-slam ini文件 rawlog文件 log文件位置
2.运行方式
1)将dealIni.sh 文件置于icp-slam文件夹下
2)将icp-slam.sh置于icp-slam文件夹下
3)在icp-slam工作目录运行命令

 ./icp-slam.sh icp_slam_demo_classic.ini all123.rawlog filelocation
 //参数说明 
 icp_slam_demo_classic.ini 可替换为自己的ini文件
 all123.rawlog可替换为自己的rawlog文件
 filelocation 为输出的log文件所在的文件夹名称,可以自行设定
 

3.源码
1)dealIni.sh

#该脚本必须用 source 命令 而且结果获取为${var}获取,不是return 如:source readIni.sh 否则变量无法外传
# dealIni.sh iniFile section option
# read
# param : iniFile section option    return value --- a str    use: ${iniValue}
# param : iniFile section           return options (element: option = value) --- a str[]   use: arr_length=${#iniOptions[*]}}  element=${iniOptions[0]}
# param : iniFile                   returm sections (element: section ) --- a str[]   use: arr_length=${#iniSections[*]}}  element=${iniSections[0]}
# write
#param : -w iniFile section option value  add new element:section option    result:if not --->creat ,have--->update,exist--->do nothing
#option ,value can not be null
 
#params
iniFile=$1
section=$2
option=$3
#sun
mode="iniR"
echo $@ | grep "\-w" >/dev/null&&mode="iniW"
if [ "$#" = "5" ]&&[ "$mode" = "iniW" ];then
   iniFile=$2
   section=$3
   option=$4
   value=$5
   #echo $iniFile $section $option $value
fi
#resullt
iniValue='default'
iniOptions=()
iniSections=()

function checkFile()
{

    #if [ "${iniFile}" = ""  ] || [ 1 ];then
    if [ "${iniFile}" = "" ] || [ ! -f ${iniFile} ]; then
        echo "[error]:file --${iniFile}-- not exist!"
    fi
}
 
function readInIfile()
{
    if [ "${section}" = "" ];then
        #通过如下两条命令可以解析成一个数组
        allSections=$(awk -F '[][]' '/\[.*]/{print $2}' ${iniFile})
        iniSections=(${allSections// /})
        echo "[info]:iniSections size:-${#iniSections[@]}- eles:-${iniSections[@]}- "
    elif [ "${section}" != "" ] && [ "${option}" = "" ];then
        #判断section是否存在
        allSe
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值