I have a irritating problem with a "if"-statement or what you should call it, in sed. I would love some help here since I am very, very stuck.
I have this statement that I want to do:
if line contains a:
do this
if none of the lines contained a:
do this
The problem with this statement is that I cant find out if it's possible and if so, how to implement this statement. In any case I've found, both "do this" will be made and I will get two outputs.
I've tried things such as:
"/searchstring/b ifpart"
"1s/^/<!-- ELSE -->/"
"b end"
":ifpart"
"s/searchstring\1<!-- IF -->/"
":end"
The problem is that in any case, the "ELSE" comment will be printed and if the searchstring is found, the IF comment will be printed as well. I only want ONE of them simultaniously, not both. I would really love to hear if it's possible or not and if you have any clue how to do it as well
Thank you!