<?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: Stuck with shell scripting... in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669044#M677809</link>
    <description>By "recent" do you mean by last modification or do you mean a date encoded in the filename?&lt;BR /&gt;&lt;BR /&gt;If it is by last modification, you could do:&lt;BR /&gt;ll -rt server* | tail -n +3&lt;BR /&gt;(This should give you the ones to remove.)</description>
    <pubDate>Mon, 02 Aug 2010 12:24:32 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2010-08-02T12:24:32Z</dc:date>
    <item>
      <title>Stuck with shell scripting...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669042#M677807</link>
      <description>Hi, Im trying to write a shell script that performs the following actions:&lt;BR /&gt;&lt;BR /&gt;- Check in a given directory how many occurrences of a file called server* (the * representes a date, obviously different for each file).&lt;BR /&gt;&lt;BR /&gt;- Leave untouched the two more recent server* entries and delete the older.&lt;BR /&gt;&lt;BR /&gt;How can be that done?&lt;BR /&gt;&lt;BR /&gt;Regards.</description>
      <pubDate>Mon, 02 Aug 2010 12:01:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669042#M677807</guid>
      <dc:creator>mpua</dc:creator>
      <dc:date>2010-08-02T12:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck with shell scripting...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669043#M677808</link>
      <description>&lt;!--!*#--&gt;&lt;BR /&gt;===&lt;BR /&gt;NUMFILES=$(ls server* | wc -l)&lt;BR /&gt;STARTLINE=$(expr $NUMFILES - 2)&lt;BR /&gt;ls server* | sed -n "$STARTLINE,\$p" | xargs echo rm&lt;BR /&gt;===&lt;BR /&gt;&lt;BR /&gt;That'll only echo the "rm" commands; remove the word "echo" if you're happy with the results of that test.&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Aug 2010 12:21:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669043#M677808</guid>
      <dc:creator>jack challen_1</dc:creator>
      <dc:date>2010-08-02T12:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck with shell scripting...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669044#M677809</link>
      <description>By "recent" do you mean by last modification or do you mean a date encoded in the filename?&lt;BR /&gt;&lt;BR /&gt;If it is by last modification, you could do:&lt;BR /&gt;ll -rt server* | tail -n +3&lt;BR /&gt;(This should give you the ones to remove.)</description>
      <pubDate>Mon, 02 Aug 2010 12:24:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669044#M677809</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-08-02T12:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck with shell scripting...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669045#M677810</link>
      <description>Ah yes. "tail", I forgot that... whoops.</description>
      <pubDate>Mon, 02 Aug 2010 12:27:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669045#M677810</guid>
      <dc:creator>jack challen_1</dc:creator>
      <dc:date>2010-08-02T12:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck with shell scripting...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669046#M677811</link>
      <description>&lt;!--!*#--&gt;Hi,&lt;BR /&gt;   Following command remove everything except recent two entries.&lt;BR /&gt;# ls -lt server* | rm `awk ' NR &amp;gt; 3 { print $NF }'`&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;Muru&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Aug 2010 03:58:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669046#M677811</guid>
      <dc:creator>muruganantham raju</dc:creator>
      <dc:date>2010-08-03T03:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck with shell scripting...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669047#M677812</link>
      <description>&amp;gt;Muru: Following command remove everything except recent two entries.&lt;BR /&gt;&amp;gt; ls -lt server* | rm $(awk 'NR &amp;gt; 3 { print $NF }')&lt;BR /&gt;&lt;BR /&gt;Your edge arithmetic is off by one, you need: NR &amp;gt; 2</description>
      <pubDate>Tue, 03 Aug 2010 05:22:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669047#M677812</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2010-08-03T05:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck with shell scripting...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669048#M677813</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;I mean modification time.&lt;BR /&gt;The tail and awk code you gave to me prints (or removes, in this case) the two more recent items of server*. &lt;BR /&gt;Is there any way of printing (in my case, removing) every server* occurrence EXCEPT the two more recent ones?&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Aug 2010 05:58:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669048#M677813</guid>
      <dc:creator>mpua</dc:creator>
      <dc:date>2010-08-03T05:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck with shell scripting...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669049#M677814</link>
      <description>I made a mistake and introduced the "-r" in the ls command. Its my fault :D. The code works perfect for what i was looking for.&lt;BR /&gt;&lt;BR /&gt;Thanks you so much!</description>
      <pubDate>Tue, 03 Aug 2010 06:09:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/stuck-with-shell-scripting/m-p/4669049#M677814</guid>
      <dc:creator>mpua</dc:creator>
      <dc:date>2010-08-03T06:09:41Z</dc:date>
    </item>
  </channel>
</rss>

