<?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: Script Help in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013284#M96536</link>
    <description>Here's a way to do it with ex(1):&lt;BR /&gt;&lt;BR /&gt;# ex -s +"$(sed -n '/RESTART/=' infile)s/0/2/p | x" infile&lt;BR /&gt;&lt;BR /&gt;~cheers</description>
    <pubDate>Thu, 09 Nov 2006 13:40:56 GMT</pubDate>
    <dc:creator>Sandman!</dc:creator>
    <dc:date>2006-11-09T13:40:56Z</dc:date>
    <item>
      <title>Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013281#M96533</link>
      <description>I have a file with contains many lines with the work RESTART separated by other stuff.  It is like this:&lt;BR /&gt;&lt;BR /&gt;stuff&lt;BR /&gt;RESTART 0&lt;BR /&gt;stuff&lt;BR /&gt;stuff&lt;BR /&gt;RESTART 0&lt;BR /&gt;stuff&lt;BR /&gt;stuff&lt;BR /&gt;RESTART 0&lt;BR /&gt;stuff&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In need to locate the last RESTART in the file and change the zero that follows it to a 2.  All other lines with RESTART should remain unchanged.  Please no Perl solutions.&lt;BR /&gt;&lt;BR /&gt;Can someone help?</description>
      <pubDate>Thu, 09 Nov 2006 12:09:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013281#M96533</guid>
      <dc:creator>Patrick Murphy</dc:creator>
      <dc:date>2006-11-09T12:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013282#M96534</link>
      <description>Quick n dirty:&lt;BR /&gt;&lt;BR /&gt;lastline=$(grep -n RESTART filename| tail -1 | cut -d: -f1)&lt;BR /&gt;awk -vll=$lastline '{if (NR==ll) print "RESTART 2"; else print $0}' filename&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Nov 2006 12:44:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013282#M96534</guid>
      <dc:creator>Jonathan Fife</dc:creator>
      <dc:date>2006-11-09T12:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013283#M96535</link>
      <description>Here's a plain and simple solution using "ed" - the standard UNIX editor:&lt;BR /&gt;&lt;BR /&gt;Put in a script:&lt;BR /&gt;&lt;BR /&gt;ed - file &amp;lt;</description>
      <pubDate>Thu, 09 Nov 2006 13:14:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013283#M96535</guid>
      <dc:creator>Zinky</dc:creator>
      <dc:date>2006-11-09T13:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013284#M96536</link>
      <description>Here's a way to do it with ex(1):&lt;BR /&gt;&lt;BR /&gt;# ex -s +"$(sed -n '/RESTART/=' infile)s/0/2/p | x" infile&lt;BR /&gt;&lt;BR /&gt;~cheers</description>
      <pubDate>Thu, 09 Nov 2006 13:40:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013284#M96536</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-11-09T13:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013285#M96537</link>
      <description>It's tempting to make tow passes through the file, like Jonathan shows. AWK could do that readily.&lt;BR /&gt;&lt;BR /&gt;If it is not too much data (less than 10MB?) then why not suck it into an array, and remember the element with the last 'RESTART'. At end fix that element and print all:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;awk 'END {l[r]="RESTART 2"; while (i++ &amp;lt; NR) { print l[i]}} {l[NR]=$0} /^RESTART 0/{ r=NR}' old.txt &amp;gt; new.txt&lt;BR /&gt;&lt;BR /&gt;Good luck,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Nov 2006 13:45:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013285#M96537</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-11-09T13:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013286#M96538</link>
      <description>ed - file &amp;lt;</description>
      <pubDate>Thu, 09 Nov 2006 13:51:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013286#M96538</guid>
      <dc:creator>Zinky</dc:creator>
      <dc:date>2006-11-09T13:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013287#M96539</link>
      <description>Thanks Jonathan it worked great.</description>
      <pubDate>Thu, 09 Nov 2006 13:55:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013287#M96539</guid>
      <dc:creator>Patrick Murphy</dc:creator>
      <dc:date>2006-11-09T13:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Script Help</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013288#M96540</link>
      <description>Jonathan's work the best for my situation.  Thanks all for your help.</description>
      <pubDate>Thu, 09 Nov 2006 13:56:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5013288#M96540</guid>
      <dc:creator>Patrick Murphy</dc:creator>
      <dc:date>2006-11-09T13:56:52Z</dc:date>
    </item>
  </channel>
</rss>

