I need to delete an empty string before matching.
So set the file:
random text more random text
I need to match the template / # matchee /, and then remove the empty line in front of it.
Here is what I tried - no success:
sed '/^[ \t]*$/{N;/#matchee.*$/{D;}}' file.txt
My logic is:
- If an empty string; add the following line to the drawing space / empty line \ n ... etc /
- If the template space contains / # matchee /, Delete up to newline yielding / # matchee /
Basically, / matchee / is a constant that should be supported, and I need to remove the extra blank line from each entry in the file of entries marked with / # matchee /.
This has no effect. I am RTFM-ing and D must remove the pattern space to a new line. Since N adds a new line plus the next line --- this should give the desired results .... alas .... no and no. Is it because the match contains almost nothing (blankline)?
source share