#!/bin/bash
#文件路径
file_path="/Users/DexLin/Desktop/项目/shell练习/测试/API22_56/apktool.yml"
#要替换的versionCode值
versionCode=40
while read line
do
line_length=${#line}
if [ $line_length -ge 11 ]
then
each_line=${line:0:11}
if [ $each_line = "versionCode" ]
then
ver_length=`expr ${#line} - 15`
#截取versionCode的值
ver_code=${line:14:$ver_length}
#生成新的文件实现替换
cat $file_path | tr $ver_code $versionCode > apktool.yml
fi
fi
done < $file_path
#!/bin/sh
if [ $# -ne 9 ];then
echo &amp;quot;usage argument 1:
Version
2:Model 3: qId 4:qKey 5:mdQke...
你似乎很少有误解妨碍你解决这个问题:您的输入文件是无效的yaml,替换mydatabase不会解决这个问题。不能有标量值用于name和映射(从键开始description)同时。我假设您的文件需要如下所示:- name: AP_DBdescription: "datasource"jndiConfig:name: jdbc/AP_DBdefinition:type: RDBMSconfigurat...
f = open('/opt/dockerfile/handle.
yml
')
x = yaml.load(f) #[{'gather_facts': False, 'tasks': [{'cp': {'d...