Stefan
Stefan

Reputation: 39

replace some string after certain other string with sed

In my config file I have an asset version like:

templating:
    engines: ['twig']
    assets_version: 20161021

When i plan to make a new release i want to replace current version (in this case 20161021) in a bash script with new version (for example with current date).

i have searched long time for examples of sed use but without success.

My Code:

sed -e 's/(::\s+assets_version:)[^=]*$/\1 assets/' app/config/config.yml

But console told me: sed: 1: "s/(::\s+assets_version: ...": \1 not defined in the RE

Can anybody help?

Upvotes: 0

Views: 95

Answers (1)

Nasr
Nasr

Reputation: 2632

VERSION=20161101
sed -i "s/assets_version.*/asserts_version: ${VERSION}/" app/config/config.yml

-i to change on the same file

assets_version.* matches assets_version and any more character on the line then replace them.

Upvotes: 1

Related Questions