Yauhen Mihura
Yauhen Mihura

Reputation: 49

Change last character in line with sed

I have the following line in my .conf file

application.release = "4"

I'm trying change it to application.release = "4.$any_value" with sed

Current pattern:

sed -c -i "s/\(application.release *= *\).*/\1\"$any_value\"/"

Could help me anybody?

Upvotes: 0

Views: 751

Answers (2)

potong
potong

Reputation: 58351

This might work for you (GNU sed):

sed -i '/^application.release = "4"$/s/"$/.$any_value"/' file

If a line contains application.release = "4" replace the last character with .$any_value"

Upvotes: 1

Beta
Beta

Reputation: 99084

Try adding one more backslash:

sed -c -i "s/\(application.release *= *\).*/\1\"\$app_version\"/"

Upvotes: 0

Related Questions