var rawText = '{"one":1,"two":2,"four":4}';
var jsonObj = JSON.parse(rawText);
var key = 'two';
var val = null;
for (prop in jsonObj) {
if (prop.match(key)) {
val = jsonObj[prop];
}
}
console.log('key: ' + key);
console.log('val: ' + val);
key: two
val: 2
-i
чтоб файл менялся in place:echo "abc" > a.txt ;sed -i 's|b|Z|' a.txt ; cat a.txt
aZc
sed -e "s/,/, ${id},/" users.txt
echo a,b,c > users.txt;read -p "ID: " id; sed -e "s/,/, ${id},/" users.txt
ID: 123456
a, 123456,b,c
div[@class='myclass']//div[@style='mystyle']
div.myclass div[style='mystyle']
jq --arg k1 "first" --arg v1 "32" --arg k2 "second" --arg v2 "32" --arg k3 "third" --arg v3 "33" '. | .[$k1]=$v1 | .[$k2]=$v2 | .[$k3]=$v3' <<<'{}' ;
{
"first": "32",
"second": "32",
"third": "33"
}
services:
webapp:
build: ./path
build:
context: .
dockerfile: Dockerfile
val: one,two,three