In my bashscript I want Sed to find debug: Debug in a file ${SourceP} and if found delete that line and export to the environment Debug=Debug
sed -i '/debug: Debug/,+0 d' ${SourceP} && export Debug=Debug
But unfortunately, the Debug=Debug is getting exported even if the pattern is not found.
How can I achieve this: export Debug=Debug only if the pattern is found and delete the line.
Is it not possible to achieve with Sed?
I tried this with awk but this also doesn't work:
awk -i inplace '!/debug: Debug/' ${SourceP} && export Debug=Debug
Edit: I hope to search for debug: Debug exactly.
debug: Debugonly at the line number = 1 of the file?For example, If line 1 contains
– Porcupine Dec 02 '18 at 22:51abcd debug: Debug xyzI expect it to work?debug: DebugError? How can we search exactly fordebug: Debug? – Porcupine Dec 02 '18 at 22:58abcd debug: Debug xyzis okay, butdebug: DebugErroris not. So you want either whitespace or nothing adjacent todebug: Debug? – Sparhawk Dec 02 '18 at 22:59