Created
September 22, 2015 21:59
-
-
Save polds/81911685fe5f3b5cad47 to your computer and use it in GitHub Desktop.
sed replace json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "a name", | |
"version": "0.3.229", | |
"dependencies": {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sed -e 's/"version": [^\"]*"/"version": "0.0.0"/g' package.json |
Current outcome:
... "version": "0.0.0"0.3.229", ...
Desired outcome:
... "version": "0.0.0", ...
In case someone reaches here, try this: https://stackoverflow.com/a/45193961/2190689
I got this to work:
sed -i'' -D 's/"version": "[0-9]*\.[0-9]*\.[0-9]*"/"version": "0.0.1"/g' package.json
Note: in some environments, it wants -E
instead of -D
. But I'm not a bash/sed expert so couldn't tell you why.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current outcome:
Desired outcome: