• 一个精确匹配的问题


    如有下面一份配置文件

    [a.properties]
    a=qwer
    b=sd
    c=cds
    [b-a.properties]
    d=fsf
    eef=fgs
    [c.a.properties]
    gsl=wr
    [d.properties]
    

    利用python的configparser模块,可以获取到的配置文件名是

    ['a.properties', 'b-a.properties', 'c.a.properties','d.properties']
    grep "^a.properties$" $res
    

      

    那么问题来了,如果在上述结果中精确找到a.properties,而不会找到b-a.properties和c.a.properties?

    办法:

    第一步:首先去除掉[,'等无用的符号,变成

    a.properties b-a.properties c.a.propertiesd.properties
    

    第二步:将上述结果的空格变成换行

    a.properties
    b-a.properties
    c.a.propertiesd.properties
    

    第三步:使用grep -w精确匹配

    grep  "^a.properties$" $res
    

    完整的脚本:

    待添加

  • 相关阅读:
    石墨烯
    spring 安装
    orm 对象关系映射
    刷机问题
    环境必备
    spring 例子
    刷系统——黑屏问题
    android 文件下载
    c# 事件处理
    回忆测试广告理论
  • 原文地址:https://www.cnblogs.com/boucher/p/5864745.html
Copyright © 2020-2023  润新知