<?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 to delete first three occurances... in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049086#M96201</link>
    <description>No, i do not want to delete the lines, just the -t</description>
    <pubDate>Thu, 24 May 2007 13:30:35 GMT</pubDate>
    <dc:creator>jmckinzie</dc:creator>
    <dc:date>2007-05-24T13:30:35Z</dc:date>
    <item>
      <title>SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049083#M96198</link>
      <description>I have a file with 5 lines.&lt;BR /&gt;all of which contain the switch -t.&lt;BR /&gt;&lt;BR /&gt;I want to move the -t off the first three occurances and leave an remaining ones alone.&lt;BR /&gt;&lt;BR /&gt;I have this command but it removed all -t within the file.&lt;BR /&gt;&lt;BR /&gt;sed 's/-t//' filename&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Any ideas?</description>
      <pubDate>Thu, 24 May 2007 13:16:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049083#M96198</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2007-05-24T13:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049084#M96199</link>
      <description>Try with:&lt;BR /&gt;&lt;BR /&gt;sed '1,3 s/-t//' filename</description>
      <pubDate>Thu, 24 May 2007 13:24:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049084#M96199</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2007-05-24T13:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049085#M96200</link>
      <description>Hi Jody:&lt;BR /&gt;&lt;BR /&gt;If by "occurances" you mean "lines":&lt;BR /&gt;&lt;BR /&gt;# sed -e '1,3s/-t//' filename&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 24 May 2007 13:25:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049085#M96200</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-24T13:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049086#M96201</link>
      <description>No, i do not want to delete the lines, just the -t</description>
      <pubDate>Thu, 24 May 2007 13:30:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049086#M96201</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2007-05-24T13:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049087#M96202</link>
      <description>Ivan,&lt;BR /&gt;&lt;BR /&gt;That did not work.&lt;BR /&gt;&lt;BR /&gt;Appreciate the help.</description>
      <pubDate>Thu, 24 May 2007 13:32:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049087#M96202</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2007-05-24T13:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049088#M96203</link>
      <description>&lt;!--!*#--&gt;What didn't work?&lt;BR /&gt;&lt;BR /&gt;I just tried the following:&lt;BR /&gt;&lt;BR /&gt;# cat test&lt;BR /&gt;-t -b&lt;BR /&gt;-t -c &lt;BR /&gt;-t -d&lt;BR /&gt;-t -e &lt;BR /&gt;-t -f&lt;BR /&gt;&lt;BR /&gt;# sed 1,3s/-t// test&lt;BR /&gt; -b&lt;BR /&gt; -c &lt;BR /&gt; -d&lt;BR /&gt;-t -e &lt;BR /&gt;-t -f&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 May 2007 13:36:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049088#M96203</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2007-05-24T13:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049089#M96204</link>
      <description>Hi (again) Jody:&lt;BR /&gt;&lt;BR /&gt;# cat .filename&lt;BR /&gt;line 1 -t&lt;BR /&gt;line 2 -t&lt;BR /&gt;line 3 -t&lt;BR /&gt;line 4 -t&lt;BR /&gt;line 5 -t&lt;BR /&gt;&lt;BR /&gt;# sed -e '1,3s/-t//' filename&lt;BR /&gt;line 1 &lt;BR /&gt;line 2 &lt;BR /&gt;line 3 &lt;BR /&gt;line 4 -t&lt;BR /&gt;line 5 -t&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 24 May 2007 13:37:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049089#M96204</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-24T13:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049090#M96205</link>
      <description># sed '1,3 s/\(.*\)-t/\1/g' file</description>
      <pubDate>Thu, 24 May 2007 13:38:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049090#M96205</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-05-24T13:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049091#M96206</link>
      <description>filename = /tmp/cron&lt;BR /&gt;&lt;BR /&gt;cat /tmp/cron&lt;BR /&gt;&lt;BR /&gt;00 03 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o -t&lt;BR /&gt;00 06 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o -t&lt;BR /&gt;00 12 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o -t &amp;gt; /tmp/tiscan 2&amp;gt;&amp;amp;1&lt;BR /&gt;00 17 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -t -o &amp;gt; /tmp/tiscan 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;sed '1,3 s/\(.*\)-t/\1/g' /tmp/cron&lt;BR /&gt;&lt;BR /&gt;doesn't work&lt;BR /&gt;neither does the one above that.&lt;BR /&gt;&lt;BR /&gt;I wonder why?</description>
      <pubDate>Thu, 24 May 2007 13:42:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049091#M96206</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2007-05-24T13:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049092#M96207</link>
      <description>It worked for me.&lt;BR /&gt;&lt;BR /&gt;Using your data in a file called test.&lt;BR /&gt;&lt;BR /&gt; $ sed 1,3s/-t// test&lt;BR /&gt;00 03 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o&lt;BR /&gt;00 06 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o&lt;BR /&gt;00 12 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o  &amp;gt; /tmp/tis&lt;BR /&gt;can 2&amp;gt;&amp;amp;1&lt;BR /&gt;00 17 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -t -o &amp;gt; /tmp/t&lt;BR /&gt;iscan 2&amp;gt;&amp;amp;1&lt;BR /&gt;</description>
      <pubDate>Thu, 24 May 2007 13:48:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049092#M96207</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2007-05-24T13:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049093#M96208</link>
      <description>Jody:&lt;BR /&gt;&lt;BR /&gt;"doesn't work"&lt;BR /&gt;&lt;BR /&gt;Exactly what output do you get?  Any errors?&lt;BR /&gt;&lt;BR /&gt;# which sed&lt;BR /&gt;&lt;BR /&gt;...reports?&lt;BR /&gt;&lt;BR /&gt;# wc -l filename&lt;BR /&gt;&lt;BR /&gt;...reports?&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Thu, 24 May 2007 13:52:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049093#M96208</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-24T13:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049094#M96209</link>
      <description>ok, does this say for the first three lines?&lt;BR /&gt;&lt;BR /&gt;what if these entries aren't in the first three lines?&lt;BR /&gt;&lt;BR /&gt;# cat cron&lt;BR /&gt;00 06 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o -t&lt;BR /&gt;00 06 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o -t&lt;BR /&gt;00 06 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o -t&lt;BR /&gt;00 12 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o -t &amp;gt; /tmp/tiscan 2&amp;gt;&amp;amp;1&lt;BR /&gt;00 17 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -t -o &amp;gt; /tmp/tiscan 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;now with SED.....&lt;BR /&gt;&lt;BR /&gt;# sed 1,3s/-t// cron&lt;BR /&gt;00 06 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o&lt;BR /&gt;00 06 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o&lt;BR /&gt;00 06 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o&lt;BR /&gt;00 12 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o -t &amp;gt; /tmp/tiscan 2&amp;gt;&amp;amp;1&lt;BR /&gt;00 17 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -t -o &amp;gt; /tmp/tiscan 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;with additional lines?&lt;BR /&gt;&lt;BR /&gt;# sed 1,3s/-t// cron&lt;BR /&gt;ewfwefj&lt;BR /&gt;wefwefwef&lt;BR /&gt;wefwefwef&lt;BR /&gt;wefwefwe&lt;BR /&gt;00 06 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o -t&lt;BR /&gt;00 06 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o -t&lt;BR /&gt;00 06 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o -t&lt;BR /&gt;00 12 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -o -t &amp;gt; /tmp/tiscan 2&amp;gt;&amp;amp;1&lt;BR /&gt;00 17 * * 0-6 /opt/TIscan/bin/scan -c /opt/TIscan/etc/sysscan.cfg -t -o &amp;gt; /tmp/tiscan 2&amp;gt;&amp;amp;1</description>
      <pubDate>Thu, 24 May 2007 13:56:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049094#M96209</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2007-05-24T13:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049095#M96210</link>
      <description>Jody:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; what if these entries aren't in the first three lines?&lt;BR /&gt;&lt;BR /&gt;You never made that clear.  However:&lt;BR /&gt;&lt;BR /&gt;# perl -nle 'm/-t/ &amp;amp;&amp;amp; $i++ &amp;lt;=2 &amp;amp;&amp;amp; s/-t//;print' filename&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>Thu, 24 May 2007 14:07:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049095#M96210</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-24T14:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049096#M96211</link>
      <description>James,&lt;BR /&gt;&lt;BR /&gt;That worked....thanks.&lt;BR /&gt;&lt;BR /&gt;Sorry for my vague description.&lt;BR /&gt;&lt;BR /&gt;for the sake of my learning sed and perl for that matter, could you explain what each character is doing?&lt;BR /&gt;&lt;BR /&gt;perl -nle 'm/-t/ &amp;amp;&amp;amp; $i++ &amp;lt;=2 &amp;amp;&amp;amp; s/-t//;print'&lt;BR /&gt;&lt;BR /&gt;perl -n (???) l (octal-what does that mean?) e (followed by a command) 'm/-t  (i do not know) &amp;amp;&amp;amp; counter &amp;lt;=2 (0-2=3) s/-t//; print'&lt;BR /&gt;&lt;BR /&gt;TIA</description>
      <pubDate>Thu, 24 May 2007 14:23:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049096#M96211</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2007-05-24T14:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049097#M96212</link>
      <description>Hi (again) Jody:&lt;BR /&gt;&lt;BR /&gt;# perl -pe 'm/\s-t\s/ &amp;amp;&amp;amp; $i++ &amp;lt;=2 &amp;amp;&amp;amp; s/-t//'&lt;BR /&gt;&lt;BR /&gt;...is a wee-bit shorter and safer.&lt;BR /&gt;&lt;BR /&gt;The '-p' says read (a line) and print.  The '-n' in the first variation says read but don't automatically print.&lt;BR /&gt;&lt;BR /&gt;The m/\s-t\s/ says match the '-t' if it is bounded by a whitespace (space, tab) character on either side.  After all, we don't match things like "this-thing".&lt;BR /&gt;&lt;BR /&gt;The &amp;amp;&amp;amp; means AND.&lt;BR /&gt;&lt;BR /&gt;The variable $i is undefined but for Perl's purpose will be zero when the code begins.  Thus for the values 0, 1 and 2 of $i, we will substitute nothing for the regular expression /-t'/.&lt;BR /&gt;&lt;BR /&gt;In all, we read the file(s) specified on the command line, looping over each line.  If we find a " -t " and we haven't counted three times, we remove it from the line we read.  In any event, every line of the file gets printed.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 24 May 2007 14:36:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049097#M96212</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-24T14:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049098#M96213</link>
      <description>Thanks a bunch...this helped significantly.&lt;BR /&gt;&lt;BR /&gt;Points have been assigned to all!</description>
      <pubDate>Thu, 24 May 2007 14:47:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049098#M96213</guid>
      <dc:creator>jmckinzie</dc:creator>
      <dc:date>2007-05-24T14:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049099#M96214</link>
      <description>Hi (again) Jody:&lt;BR /&gt;&lt;BR /&gt;Although a bit more advanced, this solution is a bit more rigorous:&lt;BR /&gt;&lt;BR /&gt;# perl -pe 'if ($i&amp;lt;3){$i++ if s/((?&amp;lt;=\W)|\A)-t(?=\W|\z)//g}' filename&lt;BR /&gt;&lt;BR /&gt;All occurances of the pattern "-t" is snipped from the number of lines tested against $i.  The pattern is sought where it is left-bounded by a non-word character or the begining of the line; and it is right-bounded by a non-word character or the end of the line. &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 24 May 2007 20:50:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049099#M96214</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-24T20:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: SED to delete first three occurances...</title>
      <link>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049100#M96215</link>
      <description>If you really really want to use sed(1) and gotos, you can try:&lt;BR /&gt;sed -e '&lt;BR /&gt;1,/-t/ {&lt;BR /&gt;s/-t//g&lt;BR /&gt;t second&lt;BR /&gt;}&lt;BR /&gt;: second&lt;BR /&gt;1,/-t/{&lt;BR /&gt;s/-t//g&lt;BR /&gt;t third&lt;BR /&gt;}&lt;BR /&gt;: third&lt;BR /&gt;1,/-t/{&lt;BR /&gt;s/-t//g&lt;BR /&gt;t fourth&lt;BR /&gt;}&lt;BR /&gt;: fourth&lt;BR /&gt;' filename&lt;BR /&gt;&lt;BR /&gt;I have no idea why it works, except sed(1) must remember where it found the first "-t" for the first block and not reevaluate it.</description>
      <pubDate>Thu, 24 May 2007 22:33:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/sed-to-delete-first-three-occurances/m-p/5049100#M96215</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-05-24T22:33:23Z</dc:date>
    </item>
  </channel>
</rss>

