<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: sed - deletion of multiple lines in a file in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116980#M686952</link>
    <description>Problem resolved</description>
    <pubDate>Wed, 09 Jul 2008 14:22:51 GMT</pubDate>
    <dc:creator>Eric Lipede</dc:creator>
    <dc:date>2008-07-09T14:22:51Z</dc:date>
    <item>
      <title>sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116958#M686930</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Scenario&lt;BR /&gt;========&lt;BR /&gt;I have a file with the word root appearing randomly in it. Ie on line 7 , 13 , 27 etc.&lt;BR /&gt;Id like to delete the line containing "root" and 2 lines above it and 2 lines below it (in a script). Any ideas?&lt;BR /&gt;thks&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Jul 2008 14:41:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116958#M686930</guid>
      <dc:creator>Eric Lipede</dc:creator>
      <dc:date>2008-07-01T14:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116959#M686931</link>
      <description>&lt;!--!*#--&gt;Hi Eric:&lt;BR /&gt;&lt;BR /&gt;# cat snip2&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $skip = 0;&lt;BR /&gt;my @lines;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    if (/root/) {&lt;BR /&gt;        $skip=2;&lt;BR /&gt;        pop @lines for (1..$skip);&lt;BR /&gt;        next;&lt;BR /&gt;    }&lt;BR /&gt;    if ($skip-- &amp;lt;= 0) {&lt;BR /&gt;        push(@lines,$_);&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;print "$_\n" for (@lines);&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...run as:&lt;BR /&gt;&lt;BR /&gt;# ./snip2 file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Jul 2008 15:21:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116959#M686931</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-07-01T15:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116960#M686932</link>
      <description>Here is a silly one-liner.&lt;BR /&gt;&lt;BR /&gt;perl -ne 'print $l3 if --$root&amp;lt;0; $l3=$l2; $l2=$l1;$l1=$_; $root=5 if /root/}{print $l3 if --$root&amp;lt;0; print $l2 if --$root&amp;lt;0; print $l1 if --$root&amp;lt;0' tmp.txt    &lt;BR /&gt;&lt;BR /&gt;In slow motion...&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt; print $l3 if --$root&amp;lt;0; # only if no root in near future&lt;BR /&gt; $l3=$l2;  # delay line...&lt;BR /&gt; $l2=$l1;&lt;BR /&gt; $l1=$_; &lt;BR /&gt; $root=5 if /root/&lt;BR /&gt;} &lt;BR /&gt;# deal with last lines;&lt;BR /&gt;print $l3 if --$root&amp;lt;0;&lt;BR /&gt;print $l2 if --$root&amp;lt;0;&lt;BR /&gt;print $l1 if --$root&amp;lt;0;&lt;BR /&gt;&lt;BR /&gt;So many ways to do it.&lt;BR /&gt;&lt;BR /&gt;This probaly codes more tightly using a simple 3 line array indexed by ( $. % 3 )&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Tue, 01 Jul 2008 15:59:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116960#M686932</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-07-01T15:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116961#M686933</link>
      <description>Hi Guys&lt;BR /&gt; points a-coming ..great perl solutions ....only we arent using perl could i bother you for the awk / sed equivalents - many thks&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;****** grep for the stars</description>
      <pubDate>Tue, 01 Jul 2008 17:24:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116961#M686933</guid>
      <dc:creator>Eric Lipede</dc:creator>
      <dc:date>2008-07-01T17:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116962#M686934</link>
      <description>&lt;!--!*#--&gt;perl -ne 'print $l[($.-3)%3] if --$root&amp;lt;0; $l[$.%3]=$_; $root=5 if /root/} {for $i ($.-2 .. $.) { print $l[$i%3] if  --$root&amp;lt;0}' tmp.txt  &lt;BR /&gt;&lt;BR /&gt;Same method of course also works in awk, but you have to not try to print for the first 3 lines.&lt;BR /&gt;&lt;BR /&gt;$ awk '(--r&amp;lt;0 &amp;amp;&amp;amp; NR&amp;gt;3) {print l[(NR-3)%3]} /root/ {r=5} {l[NR%3]=$0} END {for (i=NR-2; i&amp;lt;=NR; i++) {if (--r&amp;lt;0) {print l[i%3]}}}'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;perl array solution pretty printed....&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;  print $l[($.-3)%3] if --$root&amp;lt;0; &lt;BR /&gt;  $l[$.%3]=$_;&lt;BR /&gt;  $root=5 if /root/;&lt;BR /&gt;}&lt;BR /&gt;for $i ($.-2 .. $.) { &lt;BR /&gt; print $l[$i%3] if  --$root&amp;lt;0&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Hein&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Jul 2008 17:50:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116962#M686934</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-07-01T17:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116963#M686935</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;TMTOWTDI.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 01 Jul 2008 17:57:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116963#M686935</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-07-01T17:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116964#M686936</link>
      <description>Hi Hein&lt;BR /&gt;Im trying to modify the awk script to:&lt;BR /&gt;delete the previous 9 lines and 9 lines after the found text "root is not locked"&lt;BR /&gt;(including the found text) &lt;BR /&gt;&lt;BR /&gt;file is....&lt;BR /&gt;*************************************************&lt;BR /&gt;Cron: The previous message is the standard output&lt;BR /&gt;      and standard error of one of your crontab commands:&lt;BR /&gt;&lt;BR /&gt;  /hpuxsw/utilities/health/unlr.sh&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;From SYSTEM-ALERT@rx86 Thu Jun 26 15:00:01 BST 2008&lt;BR /&gt;Received: (from root@localhost)&lt;BR /&gt;        by x.sw.corp (8.11.1 (PHNE_35485)/8.11.1) id m5QE01218793&lt;BR /&gt;        for root; Thu, 26 Jun 2008 15:00:01 +0100 (BST)&lt;BR /&gt;Date: Thu, 26 Jun 2008 15:00:01 +0100 (BST)&lt;BR /&gt;From: SYSTEM-ALERT@rx86&lt;BR /&gt;Message-Id: &amp;lt;200806261400.m5QE01218793@lonunix2.sw.corp&amp;gt;&lt;BR /&gt;Subject: cron&lt;BR /&gt;&lt;BR /&gt;root is not locked&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;*************************************************&lt;BR /&gt;Cron: The previous message is the standard output&lt;BR /&gt;      and standard error of one of your crontab commands:&lt;BR /&gt;&lt;BR /&gt;  /hpuxsw/utilities/health/unlr.sh&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;...not having much joy ! :-(&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Jul 2008 18:16:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116964#M686936</guid>
      <dc:creator>Eric Lipede</dc:creator>
      <dc:date>2008-07-01T18:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116965#M686937</link>
      <description>Hi Eric:&lt;BR /&gt;&lt;BR /&gt;Well, you could modify the Perl script I suggested in response to your last query.&lt;BR /&gt;&lt;BR /&gt;Change:&lt;BR /&gt;&lt;BR /&gt;$skip=2;&lt;BR /&gt;&lt;BR /&gt;to &lt;BR /&gt;&lt;BR /&gt;$skip=9;&lt;BR /&gt;&lt;BR /&gt;...and anchor (with a caret) the match for the word "root" like:&lt;BR /&gt;&lt;BR /&gt;if (/^root/) {&lt;BR /&gt;&lt;BR /&gt;As I said, TMTOWTDI.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Jul 2008 18:28:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116965#M686937</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-07-01T18:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116966#M686938</link>
      <description>Hi (again) Eric:&lt;BR /&gt;&lt;BR /&gt;I hope that your lack of credit for my efforts isn't a case of "Condemnant quod non intellegunt" but rather a simple, unintentional oversight.&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 01 Jul 2008 19:09:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116966#M686938</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-07-01T19:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116967#M686939</link>
      <description>&lt;!--!*#--&gt;Eric&amp;gt;&amp;gt; only we arent using perl could i bother you for the awk / sed equivalents &lt;BR /&gt;&lt;BR /&gt;I had need seen this when i volunteerd the awk solution. I probably would not have done the awk alternate had I read that :^).&lt;BR /&gt;&lt;BR /&gt;Please consider ANY solution when kindly offered, and reward the effort.&lt;BR /&gt;Admittedly you did mention 'sed' in the subject. &lt;BR /&gt;&lt;BR /&gt;Let's face is you ( your peers ) could not solve it in the language of your choice, so clearly (for me) that language holds no (maintenance) advantage.&lt;BR /&gt;Any non-sed solution is surely just as hard (easy) to understand / maintain whether it be perl or awk or shell or any other 'likely to be available' language.&lt;BR /&gt;&lt;BR /&gt;Anyway...&lt;BR /&gt;&lt;BR /&gt;Eric&amp;gt;&amp;gt; Im trying to modify the awk script to:&lt;BR /&gt;&lt;BR /&gt;Well, my first awk and perl suggestions would be too tedious to grow the 'delay line / bucket brigade'&lt;BR /&gt;&lt;BR /&gt;The second awk suggestion, with the array, is more flexible, but was spinkled with delete window dependend contants.&lt;BR /&gt;&lt;BR /&gt;James's solution is much cleaner in that he need to set the number of lines to skip just once: $skip=2;&lt;BR /&gt;So just one edit needed to change to 9 lines.&lt;BR /&gt;&lt;BR /&gt;His solution build a potentiall very large array of lines to keep, so he can print it all at the end. Note, his solution might miss a re-occurance of 'root' in the deleted lines which may or might not be desirable. With the newer specification it is clear that is a moot point thought.&lt;BR /&gt;&lt;BR /&gt;My solution has a one-on-one print but 'lagging' by N lines. So it has the drwaback of needing to fix what is still in the queue on reading the last record.&lt;BR /&gt;&lt;BR /&gt;Anyway here is an (awk) version of the script with the 'Window' exposed as variable:&lt;BR /&gt;&lt;BR /&gt;------------- filter.awk -----------&lt;BR /&gt;BEGIN { Window = 9 + 1}&lt;BR /&gt;(--Count&amp;lt;0 &amp;amp;&amp;amp; NR &amp;gt; Window ) {print line[(NR - Window)%Window]}&lt;BR /&gt;/root is not locked/ {Count=2*Window - 1}&lt;BR /&gt;{line[NR%Window]=$0}&lt;BR /&gt;END {&lt;BR /&gt;  for (i=NR-Window; i&lt;NR&gt;&lt;/NR&gt;    i++;&lt;BR /&gt;    if (--Count&amp;lt;0) {&lt;BR /&gt;       print line[i%Window];&lt;BR /&gt;    }&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;------------------&lt;BR /&gt;&lt;BR /&gt;awk -f filter.awk &lt;TEXT file=""&gt;&lt;BR /&gt;&lt;BR /&gt;cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;/TEXT&gt;</description>
      <pubDate>Tue, 01 Jul 2008 21:14:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116967#M686939</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-07-01T21:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116968#M686940</link>
      <description>&amp;gt;I'd like to delete the line containing "root" and 2 lines above it and 2 lines below it (in a script).&lt;BR /&gt;&lt;BR /&gt;The gnu grep has a -C option to list the N lines before and after a match.  I don't know if the -v option will remove them?</description>
      <pubDate>Tue, 01 Jul 2008 21:34:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116968#M686940</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-07-01T21:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116969#M686941</link>
      <description>HI Eric:&lt;BR /&gt;&lt;BR /&gt;You said, "only we arent using perl" and yet Perl was wholly appropriate in an earlier thread of yours:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1199213" target="_blank"&gt;http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1199213&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Credit for the help I offered you therein would be appreciated, too.  Thanks.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 01 Jul 2008 22:56:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116969#M686941</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-07-01T22:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116970#M686942</link>
      <description>I of course thank all of you for your invaluable help. I cant help however be slighty bemused over the preciousness of the use of languages.  Surely, the requestor (me) has the choice of language and more to the point, regardless of the "appropriateness" of a solution, that solution may not be the right one or indeed the best. For those of you that have worked in big organizations, the choice of one language over another sometimes may range from political to out right ignorance. Whatever the case, just because Perl is appropriate does not make it the best to use. I love Perl for the detractors out there btw. Its just that in THIS case , awk and sed would be the route to go down ...as i indicated in my original request - further adding credance to the "theres method in the maddness". I asked for a sed solution and i got it - thks again. ....i do love the "and another thing" ....these threads tend to produce.&lt;BR /&gt;&lt;BR /&gt;Thks again - and points awarded!</description>
      <pubDate>Wed, 02 Jul 2008 03:51:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116970#M686942</guid>
      <dc:creator>Eric Lipede</dc:creator>
      <dc:date>2008-07-02T03:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116971#M686943</link>
      <description>...btw James - I did use Perl at the Company I worked at when that thread was generated. The Company I work at now doesnt.&lt;BR /&gt;&lt;BR /&gt;...its ALL good.&lt;BR /&gt;&lt;BR /&gt;;-)</description>
      <pubDate>Wed, 02 Jul 2008 03:55:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116971#M686943</guid>
      <dc:creator>Eric Lipede</dc:creator>
      <dc:date>2008-07-02T03:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116972#M686944</link>
      <description>Hi (again) Eric:&lt;BR /&gt;&lt;BR /&gt;Your closing points are well taken.  I'm not (usuallly) one to fall into a Holy War over languages, despite my love for Perl.&lt;BR /&gt;&lt;BR /&gt;Your comments shed light on the "madness" indeed, and I appreciate you sharing them!&lt;BR /&gt;&lt;BR /&gt;NO points for this, please.  As you said, "it's ALL good"!&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 02 Jul 2008 11:20:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116972#M686944</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-07-02T11:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116973#M686945</link>
      <description>&amp;gt;ME: I don't know if the -v option will remove them?&lt;BR /&gt;&lt;BR /&gt;It appears that -v and -C## fails to play nicely together.  :-(</description>
      <pubDate>Mon, 07 Jul 2008 23:40:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116973#M686945</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-07-07T23:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116974#M686946</link>
      <description>Hi&lt;BR /&gt;this is working quite sweetly now ...&lt;BR /&gt;&lt;BR /&gt;ROOTMAIL="/var/mail/root"&lt;BR /&gt;SCRATCH="/hpuxsw/utilities/health/logs/manage_mail.`date +%d%m%y-%T`"&lt;BR /&gt;let i=0&lt;BR /&gt;export STATE=CONTINUE&lt;BR /&gt;&lt;BR /&gt;clean_file_1()&lt;BR /&gt;{&lt;BR /&gt;while [[ "$STATE" = "CONTINUE" ]]&lt;BR /&gt;do&lt;BR /&gt; cat $ROOTMAIL | while read&lt;BR /&gt; do&lt;BR /&gt;  let i=$i+1&lt;BR /&gt;  if&lt;BR /&gt;    echo "${REPLY}" | grep "root is not locked"   &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;  then&lt;BR /&gt;    if [ "$i-9" -lt 1 ]&lt;BR /&gt;    then&lt;BR /&gt;      echo "Value of FROM = $FROM"&lt;BR /&gt;      echo "Error"&lt;BR /&gt;      exit&lt;BR /&gt;    else&lt;BR /&gt;      let FROM=$i-9;export FROM&lt;BR /&gt;      let TO=$i+9;export TO&lt;BR /&gt;    fi&lt;BR /&gt;    sed "$FROM,$TO"d $ROOTMAIL  &amp;gt; $SCRATCH&lt;BR /&gt;    cat $SCRATCH &amp;gt; $ROOTMAIL&lt;BR /&gt;  fi&lt;BR /&gt; done&lt;BR /&gt;check_file_1&lt;BR /&gt;done&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;check_file_1()&lt;BR /&gt;{&lt;BR /&gt;if&lt;BR /&gt;  grep "root is not locked"  $ROOTMAIL &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;then&lt;BR /&gt;  export STATE=CONTINUE&lt;BR /&gt;  let i=0&lt;BR /&gt;else&lt;BR /&gt;  export STATE=STOP&lt;BR /&gt;  if [ -f $SCRATCH ]&lt;BR /&gt;  then&lt;BR /&gt;    rm $SCRATCH&lt;BR /&gt;  fi&lt;BR /&gt;fi&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#############&lt;BR /&gt;# Start&lt;BR /&gt;#############&lt;BR /&gt;&lt;BR /&gt;clean_file_1&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Jul 2008 04:26:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116974#M686946</guid>
      <dc:creator>Eric Lipede</dc:creator>
      <dc:date>2008-07-08T04:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116975#M686947</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;you can use GNU grep like this:&lt;BR /&gt;/usr/local/bin/grep -A 2 -B 2 root file&lt;BR /&gt;&lt;BR /&gt;#&amp;gt; cat /tmp/file&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;root&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;6&lt;BR /&gt;7&lt;BR /&gt;8&lt;BR /&gt;&lt;BR /&gt;#&amp;gt; /usr/local/bin/grep -A 2 -B 2 root /tmp/file&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;root&lt;BR /&gt;4&lt;BR /&gt;5&lt;BR /&gt;&lt;BR /&gt;#&amp;gt;&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Regards,&lt;BR /&gt;Cedrick Gaillard</description>
      <pubDate>Tue, 08 Jul 2008 06:36:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116975#M686947</guid>
      <dc:creator>mobidyc</dc:creator>
      <dc:date>2008-07-08T06:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116976#M686948</link>
      <description>&lt;!--!*#--&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;don't forget to add the -v flag for delete the lines you don't want:&lt;BR /&gt;&lt;BR /&gt;/usr/local/bin/grep -v -A 2 -B 2 root /tmp/file &amp;gt; /tmp/file.tmp &amp;amp;&amp;amp; mv /tmp/file.tmp /tmp/file&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Regards,&lt;BR /&gt;Cedrick Gaillard</description>
      <pubDate>Tue, 08 Jul 2008 06:56:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116976#M686948</guid>
      <dc:creator>mobidyc</dc:creator>
      <dc:date>2008-07-08T06:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: sed - deletion of multiple lines in a file</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116977#M686949</link>
      <description>&amp;gt;mobidyc: don't forget to add the -v flag&lt;BR /&gt;&lt;BR /&gt;My 2.5.1 doesn't handle -v with either -C or -A/-B.</description>
      <pubDate>Tue, 08 Jul 2008 07:20:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-deletion-of-multiple-lines-in-a-file/m-p/5116977#M686949</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-07-08T07:20:09Z</dc:date>
    </item>
  </channel>
</rss>

