Directory structure:
$ tree
.
├── a
│ ├── a
│ │ ├── other.json
│ │ └── package.json
│ ├── other.json
│ └── package.json
├── b
│ ├── other.json
│ └── package.json
└── c
├── other.json
└── package.json
4 directories, 8 files
File contents before:
$ find . -name package.json -type f -print -exec cat {} \;
./a/a/package.json
{
"this": "0.3.1"
}
./a/package.json
{
"this": "0.3.1"
}
./b/package.json
{
"this": "0.3.1"
}
./c/package.json
{
"this": "0.3.1"
}
Replace the version:
$ find . -name package.json -type f -maxdepth 2 -print -exec sed -i '' -e 's/"this": "0.3.1"/"this": "0.4.0"/' {} \;
./a/package.json
./b/package.json
./c/package.json
Contents after:
$ find . -name package.json -type f -print -exec cat {} \;
./a/a/package.json
{
"this": "0.3.1"
}
./a/package.json
{
"this": "0.4.0"
}
./b/package.json
{
"this": "0.4.0"
}
./c/package.json
{
"this": "0.4.0"
}