Answer the question
In order to leave comments, you need to log in
How to prevent write using SED if value exists?
There is a 1.conf file with the contents:
/opt/pki/ca.crt
/opt/pki/ca.key It is
necessary to add after ".crt" for example "Ivanov"
Everything is clear here:
#!/bin/bash
filename="/opt /pki/1.conf"
search=".crt"
replace="Ivanov"
if ; then
sed -i "s/$search/& $replace/" $filename
fi
What if /opt/pki/1.conf already contains:
/opt/pki/ca.crt Ivanov
/opt/pki/ca. key
On restart it adds "/opt/pki/ca.crt Ivanov Ivanov" :(
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question