<?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 to delete files in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084629#M441285</link>
    <description>in know it's closed but here's one more way ...more to that find command.&lt;BR /&gt;&lt;BR /&gt;log files older than 2 days get gzipped.&lt;BR /&gt;log files older than 5 days get deleted.&lt;BR /&gt;I run the find command from the spot where the files are so I do not accidentally delete stuff I care about.  I also use the -name option in find for the same reason. &lt;BR /&gt;&lt;BR /&gt;cd /directory/path&lt;BR /&gt;find . -type f -mtime 2 -name "log*" -exec gzip {}  \;&lt;BR /&gt;&lt;BR /&gt;find . -type f -mtime 5 -name "log*gz" -exec rm {}  \;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And here's another way&lt;BR /&gt;&lt;BR /&gt;cd /directory/path&lt;BR /&gt;LIST1=`find . -type f -mtime 2 -name "log*"`&lt;BR /&gt;&lt;BR /&gt;for F in $LIST1&lt;BR /&gt;   do&lt;BR /&gt;   gzip $F&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 19 Dec 2007 14:44:59 GMT</pubDate>
    <dc:creator>Steve Post</dc:creator>
    <dc:date>2007-12-19T14:44:59Z</dc:date>
    <item>
      <title>Script to delete files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084622#M441278</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I have some programs/scripts in HP-UX which generate logs by name/date series continuously.&lt;BR /&gt;&lt;BR /&gt;I want to delete those files using script without deleting the last 2-3 files using creation date.&lt;BR /&gt;&lt;BR /&gt;Can anyone help me regarding this?</description>
      <pubDate>Tue, 18 Dec 2007 03:23:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084622#M441278</guid>
      <dc:creator>Jeeshan</dc:creator>
      <dc:date>2007-12-18T03:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Script to delete files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084623#M441279</link>
      <description>If the file is created with a sortable date (one with YYYYMMDDHHSS numbers only), you can just use:&lt;BR /&gt;$ echo rm -f $(ll -r prefix* | awk '{print $9}' | tail -n +4)&lt;BR /&gt;&lt;BR /&gt;Remove the echo if you are happy with what you are removing.&lt;BR /&gt;&lt;BR /&gt;If the files don't have a sortable name and you can assume the last modification date is ordered, you can use "ll -t".</description>
      <pubDate>Tue, 18 Dec 2007 03:44:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084623#M441279</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-12-18T03:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: Script to delete files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084624#M441280</link>
      <description>Bear in mind that unless the creation date is carried in the name of the file itself (or you have those data stored in another file) that what you ask is not possible. UNIX has no notion of the creation date of a file. If one of the other timestamps (atime, ctime, or mtime) happens to match the creation time of a file it is nothing more and nothing less than coincidence.</description>
      <pubDate>Tue, 18 Dec 2007 04:32:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084624#M441280</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-12-18T04:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Script to delete files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084625#M441281</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;find . -mtime 1 -type f -name *.log | xargs rm&lt;BR /&gt;&lt;BR /&gt;this will rmove your file modified between 24 and 48 hours ago (about creation see previos post). Type the correct regular expression istead of *.log&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Wed, 19 Dec 2007 09:01:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084625#M441281</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2007-12-19T09:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: Script to delete files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084626#M441282</link>
      <description>Thanks Dennis for your support&lt;BR /&gt;&lt;BR /&gt;What i wanna do is, i have a directory which contains files like this manner&lt;BR /&gt;&lt;BR /&gt;-rw-r--r--   1 user      group         24033 Dec 19 13:05 History_2007121913.log&lt;BR /&gt;-rw-r--r--   1 user      group         24110 Dec 19 14:04 History_2007121914.log&lt;BR /&gt;-rw-r--r--   1 user      group         23575 Dec 19 15:04 History_2007121915.log&lt;BR /&gt;&lt;BR /&gt;Last log is running. If i want to delete the files keeping the last one what will be the procedure?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 19 Dec 2007 09:09:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084626#M441282</guid>
      <dc:creator>Jeeshan</dc:creator>
      <dc:date>2007-12-19T09:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: Script to delete files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084627#M441283</link>
      <description>&amp;gt;i have a directory which contains files like this manner&lt;BR /&gt;History_2007121913.log&lt;BR /&gt;&lt;BR /&gt;These are ordered by name.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;If i want to delete the files keeping the last one what will be the procedure?&lt;BR /&gt;&lt;BR /&gt;$ echo rm -f $(ll -r History_* | awk '{print $9}' | tail -n +2)&lt;BR /&gt;&lt;BR /&gt;Remove the "echo" when you are sure it removes only the files you want.</description>
      <pubDate>Wed, 19 Dec 2007 09:58:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084627#M441283</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-12-19T09:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: Script to delete files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084628#M441284</link>
      <description>thanks all</description>
      <pubDate>Wed, 19 Dec 2007 11:21:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084628#M441284</guid>
      <dc:creator>Jeeshan</dc:creator>
      <dc:date>2007-12-19T11:21:00Z</dc:date>
    </item>
    <item>
      <title>Re: Script to delete files</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084629#M441285</link>
      <description>in know it's closed but here's one more way ...more to that find command.&lt;BR /&gt;&lt;BR /&gt;log files older than 2 days get gzipped.&lt;BR /&gt;log files older than 5 days get deleted.&lt;BR /&gt;I run the find command from the spot where the files are so I do not accidentally delete stuff I care about.  I also use the -name option in find for the same reason. &lt;BR /&gt;&lt;BR /&gt;cd /directory/path&lt;BR /&gt;find . -type f -mtime 2 -name "log*" -exec gzip {}  \;&lt;BR /&gt;&lt;BR /&gt;find . -type f -mtime 5 -name "log*gz" -exec rm {}  \;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;And here's another way&lt;BR /&gt;&lt;BR /&gt;cd /directory/path&lt;BR /&gt;LIST1=`find . -type f -mtime 2 -name "log*"`&lt;BR /&gt;&lt;BR /&gt;for F in $LIST1&lt;BR /&gt;   do&lt;BR /&gt;   gzip $F&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 19 Dec 2007 14:44:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-to-delete-files/m-p/5084629#M441285</guid>
      <dc:creator>Steve Post</dc:creator>
      <dc:date>2007-12-19T14:44:59Z</dc:date>
    </item>
  </channel>
</rss>

