G
G
gto61202016-12-16 12:43:08
linux
gto6120, 2016-12-16 12:43:08

How to do a proper substitution with sed?

There is a conditional config:

user = u1
second.user = u2

gotta get
user = my_u1
second.user = u2

doing
sed -i '/user/s/= .*/= my_u1/' ${PATH_CONFIG_FILE}
I get
user = my_u1
second.user = my_u1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max, 2016-12-16
@gto6120

sed -i '/^user/s/= .*/= my_user_1/' ${PATH_CONFIG_FILE}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question