Background
Original json (test.json
): {"rpc-password": "password"}
Expected changed json: {"rpc-password": "somepassword"}
replace_json_str
is a function used to replace password
with somepassword
using sed
.
replace_json_str() {
x=$1
sed -i -e 's/\({ "'"$2"'":\)"[^"]*" }/\1"'"$3"'" }/g' $x
}
Unit test: replace_json_str test.json rpc-password somepassword
Issue
After running the above test, I get a file named test.json-e
and the contents of the file is the same as before the test was ran, why?