<?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: How do I create a script to Purge all files in a Directory except for the latest 100??? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438164#M6115</link>
    <description>Instead of :&lt;BR /&gt;echo $FILE&lt;BR /&gt;&lt;BR /&gt;You should put rm $FILE&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Victor</description>
    <pubDate>Mon, 21 Aug 2000 17:56:48 GMT</pubDate>
    <dc:creator>Victor BERRIDGE</dc:creator>
    <dc:date>2000-08-21T17:56:48Z</dc:date>
    <item>
      <title>How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438148#M6099</link>
      <description />
      <pubDate>Mon, 21 Aug 2000 15:32:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438148#M6099</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-21T15:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438149#M6100</link>
      <description>Shaun:&lt;BR /&gt;&lt;BR /&gt;Please define what you mean by "latest".  Is this a modification timestamp, or simply the last 100 files in a directory, as ordered by normal collation?&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 21 Aug 2000 15:35:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438149#M6100</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-08-21T15:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438150#M6101</link>
      <description>Thanks for the reply. To clarify this better I am looking for more of a script which will delete all but the latest 100 files in the directory according to timestamp.&lt;BR /&gt;&lt;BR /&gt;I am not very good at all at creating scripts so any help is greatly appreciated!!!&lt;BR /&gt;&lt;BR /&gt;Thanks, Shaun Aldrich&lt;BR /&gt;&lt;BR /&gt;You can email me at SAldrich@chaptersinc.com</description>
      <pubDate>Mon, 21 Aug 2000 15:44:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438150#M6101</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-21T15:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438151#M6102</link>
      <description>Try this:&lt;BR /&gt;&lt;BR /&gt;rm `ls -1t | tail +102`&lt;BR /&gt;&lt;BR /&gt;Please test this on some unneeded files first to insure it works as desired!&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Aug 2000 15:58:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438151#M6102</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2000-08-21T15:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438152#M6103</link>
      <description>rm $(ls -t|head -n100 )</description>
      <pubDate>Mon, 21 Aug 2000 16:08:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438152#M6103</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2000-08-21T16:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438153#M6104</link>
      <description>Shaun:&lt;BR /&gt;&lt;BR /&gt;Try something like this:&lt;BR /&gt;&lt;BR /&gt;FILES=`ls -t $MYDIR` #...collect by mod time&lt;BR /&gt;COUNT=`echo $FILES | wc -w` #...get how many&lt;BR /&gt;let N=COUNT-100  #...keep 100 of them...&lt;BR /&gt;FILES=`echo $FILES | cut -f1-$N -d " "`&lt;BR /&gt;rm $R&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Aug 2000 16:11:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438153#M6104</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-08-21T16:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438154#M6105</link>
      <description>Shaun:&lt;BR /&gt;&lt;BR /&gt;Sorry, the script should look like:&lt;BR /&gt;&lt;BR /&gt;Shaun: &lt;BR /&gt;&lt;BR /&gt;Try something like this: &lt;BR /&gt;&lt;BR /&gt;FILES=`ls -t $MYDIR` #...collect by mod time &lt;BR /&gt;COUNT=`echo $FILES | wc -w` #...get how many &lt;BR /&gt;let N=COUNT-100 #...keep 100 of them... &lt;BR /&gt;FILES=`echo $FILES | cut -f1-$N -d " "` #...list's head &lt;BR /&gt;rm $FILES&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Aug 2000 16:17:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438154#M6105</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-08-21T16:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438155#M6106</link>
      <description>Thanks a lot James...&lt;BR /&gt;&lt;BR /&gt;Is that the only 5 lines I would need in my script? Like I said, unfortunately my scripting ability is very poor right now.&lt;BR /&gt;&lt;BR /&gt;Shaun Aldrich</description>
      <pubDate>Mon, 21 Aug 2000 16:37:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438155#M6106</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-21T16:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438156#M6107</link>
      <description>My first solution was too short?&lt;BR /&gt;OK&lt;BR /&gt;What about with FOR :&lt;BR /&gt;#&lt;BR /&gt;for FILE in `ls -t|head -n10`&lt;BR /&gt;do&lt;BR /&gt;     rm $FILE&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Victor&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Aug 2000 16:55:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438156#M6107</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2000-08-21T16:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438157#M6108</link>
      <description>Shaun:&lt;BR /&gt;&lt;BR /&gt;Other than defining $MYDIR to that of your choosing, yes, the script is complete as written.  You could define MYDIR as, for instance MYDIR=/tmp/log* to match all files beginning with "log" in the /tmp.&lt;BR /&gt;&lt;BR /&gt;My suggestion is but one solution.  Welcome to UNIX where there is always more than one way to do anything!!!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 21 Aug 2000 17:02:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438157#M6108</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-08-21T17:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438158#M6109</link>
      <description>Hi Victor,&lt;BR /&gt;&lt;BR /&gt;Thanks for the response. In the first line of the FOR LOOP what is the second word FILE specified for?  Is it a variable?&lt;BR /&gt;&lt;BR /&gt;Will this delete all of the files in the directory except for the latest 100 in terms of timestamp?&lt;BR /&gt;&lt;BR /&gt;Your help is greatly appreciated...</description>
      <pubDate>Mon, 21 Aug 2000 17:04:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438158#M6109</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-21T17:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438159#M6110</link>
      <description>Sorry Shaun, &lt;BR /&gt;I was on the phone while writing the first post and got confused with what I was asked by phone...&lt;BR /&gt;Of course not my script would have erased the last 100..&lt;BR /&gt;Since you want to keep the last 100 there is the solution that James put down for you:&lt;BR /&gt;1) count first to know how many files to be removed&lt;BR /&gt;2) remove them.&lt;BR /&gt;&lt;BR /&gt;Other solutions exists but James has an elegant one...&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Victor</description>
      <pubDate>Mon, 21 Aug 2000 17:20:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438159#M6110</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2000-08-21T17:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438160#M6111</link>
      <description>lets hope this one is a good one, so that you can forgive me...&lt;BR /&gt;&lt;BR /&gt;for FILE in `ls |grep -v "$(ls -t|head -n100)"`&lt;BR /&gt;do&lt;BR /&gt;                echo $FILE&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;James, I want your comments, what do you think of this?&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Victor</description>
      <pubDate>Mon, 21 Aug 2000 17:41:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438160#M6111</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2000-08-21T17:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438161#M6112</link>
      <description>What happens if there are less than 100 files?</description>
      <pubDate>Mon, 21 Aug 2000 17:43:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438161#M6112</guid>
      <dc:creator>Ed Hon</dc:creator>
      <dc:date>2000-08-21T17:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438162#M6113</link>
      <description>with the echo instead of rm I tried when ther is less and got not candidates echoed, thus me asking your advice (well James...) on can you trust this result?&lt;BR /&gt;&lt;BR /&gt;Victor</description>
      <pubDate>Mon, 21 Aug 2000 17:48:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438162#M6113</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2000-08-21T17:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438163#M6114</link>
      <description>Hi Victor,&lt;BR /&gt;&lt;BR /&gt;Where do you put the rm command within the four lines of the statement you just sent me? All files but the latest 100 must be deleted in the directory. Does the rm command go in after that 4 line statement?&lt;BR /&gt;&lt;BR /&gt;Thanks for your help Victor and others....</description>
      <pubDate>Mon, 21 Aug 2000 17:52:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438163#M6114</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-21T17:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438164#M6115</link>
      <description>Instead of :&lt;BR /&gt;echo $FILE&lt;BR /&gt;&lt;BR /&gt;You should put rm $FILE&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Victor</description>
      <pubDate>Mon, 21 Aug 2000 17:56:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438164#M6115</guid>
      <dc:creator>Victor BERRIDGE</dc:creator>
      <dc:date>2000-08-21T17:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438165#M6116</link>
      <description>Shaun:&lt;BR /&gt;&lt;BR /&gt;Victor's solution is an elegant solution too.&lt;BR /&gt;&lt;BR /&gt;Shaun, you might want to add some logic to exit if there are less than 100 files.  In total, a recap of my solution is as follows.  Variables are in UPPERCASE.&lt;BR /&gt;&lt;BR /&gt;MYDIR=/tmp/mylog*    #...whatever...&lt;BR /&gt;FILES=`ls -t $MYDIR` #...collect by mod time &lt;BR /&gt;COUNT=`echo $FILES | wc -w` #...get how many &lt;BR /&gt;if (( COUNT &amp;lt; 100 ))&lt;BR /&gt;then&lt;BR /&gt;exit 0&lt;BR /&gt;fi&lt;BR /&gt;let N=COUNT-100 #...keep 100 of them... &lt;BR /&gt;FILES=`echo $FILES | cut -f1-$N -d " "` #...list's head &lt;BR /&gt;rm $FILES &lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Aug 2000 17:59:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438165#M6116</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-08-21T17:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438166#M6117</link>
      <description>rm `ls -1t | tail +101`  &lt;BR /&gt;&lt;BR /&gt;will work even if there are less than 100 files.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Aug 2000 18:07:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438166#M6117</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2000-08-21T18:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a script to Purge all files in a Directory except for the latest 100???</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438167#M6118</link>
      <description>Shaun:&lt;BR /&gt;&lt;BR /&gt;Please remember that points for those of us who have provided input are greatly appreciated!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 21 Aug 2000 18:10:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-do-i-create-a-script-to-purge-all-files-in-a-directory/m-p/2438167#M6118</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2000-08-21T18:10:15Z</dc:date>
    </item>
  </channel>
</rss>

