In a file containing lines like this one:# lorem ipsum blah variableI would like to remove # (comment) character in the same line that contains a specific string, in place. Is sed good for this? I'm struggling to get this conditional working. I have a clumsy way of doing this; I can find the matching line number with awk or sed and then use this number in a separate sed command, but I believe that this can be done in a much better way.
Sed --- replace a character in a matched line in place?
sed
Use the string you are looking for as the selector for the lines to be operated upon:sed '/ipsum/s/#//g'/ipsum/ selects lines containing ipsum and only on these lines the command(s) that follow are executed. You can use braces to run more commands/ipsum/{s/#//g;s/@/-at-/g;}