<?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/2438178#M6129</link>
    <description>Thanks Chris... Is that the only line I would need in the script? I really appreciate your help. &lt;BR /&gt;&lt;BR /&gt;Shaun Aldrich</description>
    <pubDate>Mon, 21 Aug 2000 16:35:03 GMT</pubDate>
    <dc:creator>Shaun Aldrich</dc:creator>
    <dc:date>2000-08-21T16:35:03Z</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/2438173#M6124</link>
      <description>How do I create a script to Purge all files in a Directory except for the latest 100??? I am currently administoring an HP-UX 10.20 server and need to create a script which will delete any files greater than 100.&lt;BR /&gt;&lt;BR /&gt;A DBA who I work with is looking for a script that inside a directory will only keep that latest 100 files. I guess the database he works with continually fills up the directory.&lt;BR /&gt;&lt;BR /&gt;Unfortunately, I am lacking in knowledge of writing scripts and if anyone has any ideas how to do this, has done any or can get me started I would greatly appreciate it.&lt;BR /&gt;&lt;BR /&gt;Thanks! You can email me at SAldrich@chaptersinc.com</description>
      <pubDate>Mon, 21 Aug 2000 15:38:59 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/2438173#M6124</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-21T15:38:59Z</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/2438174#M6125</link>
      <description>Include this line in your script:&lt;BR /&gt;find . -mtime +100 -ok rm {} \;</description>
      <pubDate>Mon, 21 Aug 2000 15:59: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/2438174#M6125</guid>
      <dc:creator>CHRIS_ANORUO</dc:creator>
      <dc:date>2000-08-21T15:59: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/2438175#M6126</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;=====begin=====&lt;BR /&gt;nr_of_files=$(ll -l /your/directory | grep ^- | wc -l)&lt;BR /&gt;set $(ls -art1 /your/directory)&lt;BR /&gt;&lt;BR /&gt;while [ $nr_of_files -gt 100 ]&lt;BR /&gt;do&lt;BR /&gt;  if [ -f $1 ]&lt;BR /&gt;  then&lt;BR /&gt;    rm $1&lt;BR /&gt;    let nr_of_files=nr_of_files-1&lt;BR /&gt;  fi&lt;BR /&gt;  shift&lt;BR /&gt;done&lt;BR /&gt;=====end======&lt;BR /&gt;&lt;BR /&gt;This should remove all but 100 regular files in the directory /your/directory.&lt;BR /&gt;&lt;BR /&gt;Bye,&lt;BR /&gt;Rik</description>
      <pubDate>Mon, 21 Aug 2000 16:00:59 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/2438175#M6126</guid>
      <dc:creator>RikTytgat</dc:creator>
      <dc:date>2000-08-21T16:00:59Z</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/2438176#M6127</link>
      <description>Thanks Rick and Chris 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 16:08:34 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/2438176#M6127</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-21T16:08:34Z</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/2438177#M6128</link>
      <description>Include this line in your script:&lt;BR /&gt;find . -mtime +100 -ok rm {} \;</description>
      <pubDate>Mon, 21 Aug 2000 16:31: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/2438177#M6128</guid>
      <dc:creator>CHRIS_ANORUO</dc:creator>
      <dc:date>2000-08-21T16:31: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/2438178#M6129</link>
      <description>Thanks Chris... Is that the only line I would need in the script? I really appreciate your help. &lt;BR /&gt;&lt;BR /&gt;Shaun Aldrich</description>
      <pubDate>Mon, 21 Aug 2000 16:35:03 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/2438178#M6129</guid>
      <dc:creator>Shaun Aldrich</dc:creator>
      <dc:date>2000-08-21T16:35:03Z</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/2438179#M6130</link>
      <description>The command is for files modified more than hundred days ago. mtime is the modification time. Read the online manual for find.</description>
      <pubDate>Mon, 21 Aug 2000 16:49:44 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/2438179#M6130</guid>
      <dc:creator>CHRIS_ANORUO</dc:creator>
      <dc:date>2000-08-21T16:49:44Z</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/2438180#M6131</link>
      <description>maybe could try:&lt;BR /&gt;&lt;BR /&gt;x=$(ls -Ft /path/path/path | grep -v "/$" | tail +100)&lt;BR /&gt;&lt;BR /&gt;for i in $(echo "$x")&lt;BR /&gt;do&lt;BR /&gt;  rm ${i}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;probably should test this.....don't know if it works right</description>
      <pubDate>Mon, 21 Aug 2000 17:05: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/2438180#M6131</guid>
      <dc:creator>wyan lowe</dc:creator>
      <dc:date>2000-08-21T17:05: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/2438181#M6132</link>
      <description>Yet another removal script.&lt;BR /&gt;Try this........&lt;BR /&gt;#! /bin/sh&lt;BR /&gt;# ---------------------------------&lt;BR /&gt;# Removes all but the last two&lt;BR /&gt;# files in the redo diretory&lt;BR /&gt;# ---------------------------------&lt;BR /&gt;X=1&lt;BR /&gt;for Files in `ls -t /path/your_file_spec_here.* `&lt;BR /&gt;  do&lt;BR /&gt;  # -------------------------------&lt;BR /&gt;  # Test for your upper limit here&lt;BR /&gt;  # -------------------------------&lt;BR /&gt;  if test $X -gt 2&lt;BR /&gt;  then&lt;BR /&gt;  echo "Removing File $Files $X"&lt;BR /&gt;  # Put your removal command here &lt;BR /&gt;  else&lt;BR /&gt;  echo $Files not removed.&lt;BR /&gt;fi&lt;BR /&gt;let X=X+1&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Aug 2000 07:00:05 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/2438181#M6132</guid>
      <dc:creator>Ray Ward</dc:creator>
      <dc:date>2000-08-22T07:00:05Z</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/2438182#M6133</link>
      <description>Shaun,&lt;BR /&gt;&lt;BR /&gt;That's exactly what my script does.&lt;BR /&gt;&lt;BR /&gt;The command 'ls -art1' gives a 1 column list of all files in the current directory, ordered from oldest ( at the top) to youngest (at the bottom). So, by deleting all files but 100 starting from the beginning of that list, you end up with the 100 youngest file in that directory.&lt;BR /&gt;&lt;BR /&gt;Right?&lt;BR /&gt;&lt;BR /&gt;Bye,&lt;BR /&gt;Rik.</description>
      <pubDate>Wed, 23 Aug 2000 18:08:22 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/2438182#M6133</guid>
      <dc:creator>RikTytgat</dc:creator>
      <dc:date>2000-08-23T18:08:22Z</dc:date>
    </item>
  </channel>
</rss>

