Skip to content

Instantly share code, notes, and snippets.

@polds
Created September 22, 2015 21:59
Show Gist options
  • Save polds/81911685fe5f3b5cad47 to your computer and use it in GitHub Desktop.
Save polds/81911685fe5f3b5cad47 to your computer and use it in GitHub Desktop.
sed replace json
{
"name": "a name",
"version": "0.3.229",
"dependencies": {}
}
sed -e 's/"version": [^\"]*"/"version": "0.0.0"/g' package.json
@polds
Copy link
Author

polds commented Sep 22, 2015

Current outcome:

...
  "version": "0.0.0"0.3.229",
...

Desired outcome:

...
  "version": "0.0.0",
...

@ssi-anik
Copy link

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

@djhouseknecht
Copy link

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