This commit is contained in:
Kiolow 2024-06-07 13:08:00 +08:00
parent b7e24949b3
commit b887abc50a

View File

@ -7,6 +7,11 @@ function modify_json_file() {
local key=$2 # 要修改的key local key=$2 # 要修改的key
local value=$3 # 要修改的value local value=$3 # 要修改的value
#如果key的值是.开头, 则去掉.号
if [[ ${key} == "."* ]]; then
key=${key:1}
fi
jq ".${key} = \"${value}\"" ${json_file} > ${json_file}.tmp jq ".${key} = \"${value}\"" ${json_file} > ${json_file}.tmp
mv ${json_file}.tmp ${json_file} mv ${json_file}.tmp ${json_file}
} }