runnerpaul
runnerpaul

Reputation: 7236

update line in js file with sed

I have this line in a file called core.js:

  VERSION: '1.2.3-0',

I also have a variable called VERSION.

In a .sh script that I'm writing I want to update VERSION: '1.2.3-0', with the version so that it would look like VERSION: '1.2.4', (or whatever vallue it's set to).

I've tried this but it did not work:

sed 's/\b^VERSION: '[^']/$VERSION/' core.js

How do I update this line?

Upvotes: 1

Views: 999

Answers (1)

Neekoy
Neekoy

Reputation: 2543

You can do it with the following command:

sed -i "s|VERSION: '1.2.3-0'|VERSION: '1.2.4'|g" core.js

When you run sed without the -i option it will just output the difference rather than apply the change.

Upvotes: 3

Related Questions