Categories
How to do a proper substitution with sed?
There is a conditional config:
user = u1 second.user = u2
user = my_u1 second.user = u2
sed -i '/user/s/= .*/= my_u1/' ${PATH_CONFIG_FILE}
user = my_u1 second.user = my_u1
Answer the question
In order to leave comments, you need to log in
sed -i '/^user/s/= .*/= my_user_1/' ${PATH_CONFIG_FILE}
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question