K
K
KaliKillah2017-06-18 11:44:44
linux
KaliKillah, 2017-06-18 11:44:44

How to check the presence of a parameter in the config and if it is not filled, then add it?

I have a config like this:

PARAM_1 = 'one'
PARAM_2 = 'two'
PARAM_3 = ''
PARAM_4 = 'four'
...
PARAM_X = 'x'

In the given example, it is necessary to check the PARAM_3 string for the presence of the text 'three' in it, and if the string is empty, as in the given example, then write this value there.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TyzhSysAdmin, 2017-06-18
@KaliKillah

sed -i "s|^PARAM_3 = ''|PARAM_3 = 'three'|" /path/to/file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question