如有下面一份配置文件
[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
完整的脚本:
待添加