Script to remove line of text

Hello,
I have a line that needs to be removed using sed -i to perform the replace in place. The issue that I have is the files on each server may contain extra rows after the last logger definition. So I can't count accurately from the last row.
So from the example the line that contains @watchdog could have 5 blank lines under it or 3.

TEXT:

# Save boot messages also to boot.log
local7.*                                                /var/log/boot.log

local1.*                                                /var/log/prod/prod.log
local1.*                                                @sysmon
local1.*                                                @watchdog

DESIRED RESULTS:

# Save boot messages also to boot.log
local7.*                                                /var/log/boot.log

local1.*                                                /var/log/prod/prod.log
local1.*                                                @watchdog

The line that contained @sysmon is gone in the desired results.

Thanks,
jaysunn

So do you want to simply eliminate the "@sysmon" line...in place that is

More details please. What criteria is used to decide which row is to be deleted? You've told us what criteria to not use...

How about simply deleting all blank lines...and not worrying about only those that are at the tail end.

Hi,
try

Thanks for helping!!
@shamrock,
Yes I just want to remove the line that contains "@sysmon".

I am sorry for wasting every ones time. After thinking about "More Criteria" that @Corona688 suggested. I think I can get away just fine with the following code below, since the row containing @sysmon is always the same. It may be at a different line number in the file, but the same. Also I am sure much more elegant solutions exist.

[root@server ~]# sed 's/local1.*                                                @sysmon//' /etc/syslog.conf

The command above does remove the line that I wanted removed.
Thanks for helping me think on my own. :b:
jaysunn

You can try this ex script for in place substitution...

ex -s +'/@sysmon$/d | wq' file

@shamrock,
Very neat ex script. What seems to happen is I got dropped into VI when running this. I need to then :q to get out.

ex -s +'/@sysmon$/d | wq' /etc/syslog.conf

Thanks,
jaysunn

That should not happen...that is what the wq command is supposed to take care of...in red above