Is it possible to change the value
of a key
in a JSON file from command line?
e.g., in package.json:
Change
{
.
One way to achieve it is by using the "json" npm package, e.g.:
json -I -f package.json -e "this.name='adar'"
Another way is by using the jq CLI, e.g.:
mv package.json temp.json
jq -r '.name |= "adar"' temp.json > package.json
rm temp.json
The anoter way is to open the file itself in terminal :
pico filename.json
edit it then save then exit.
check if correct changes were made:
cat filename.json