<?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: date script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651960#M46243</link>
    <description>Hi Dottie,&lt;BR /&gt;&lt;BR /&gt;I suppouse that you have files with names like this:&lt;BR /&gt;&lt;BR /&gt;filename.yyyymmdd&lt;BR /&gt;&lt;BR /&gt;If it is you can do a script that keep the today date and rm all the files with an extension minor than today.&lt;BR /&gt;&lt;BR /&gt;Something like this:&lt;BR /&gt;&lt;BR /&gt;cd your directory&lt;BR /&gt;date=$(date +%Y +%b +%d)&lt;BR /&gt;for i in `ls`&lt;BR /&gt;do&lt;BR /&gt;extension=$(echo $i | cut -d. -f2)&lt;BR /&gt;if [ $extension -lt $date ]&lt;BR /&gt;then&lt;BR /&gt;file="\*"+"\."+${extension}&lt;BR /&gt;rm ${file}&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Justo.</description>
    <pubDate>Thu, 24 Jan 2002 12:53:00 GMT</pubDate>
    <dc:creator>Justo Exposito</dc:creator>
    <dc:date>2002-01-24T12:53:00Z</dc:date>
    <item>
      <title>date script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651957#M46240</link>
      <description>I am trying to write a script that will delete a file with the extention of the prior days date and everything that I have tried doesn't work. I don't want to delete the file with the current date as its extention.&lt;BR /&gt;What am I missing.&lt;BR /&gt;&lt;BR /&gt;thanks</description>
      <pubDate>Thu, 24 Jan 2002 12:14:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651957#M46240</guid>
      <dc:creator>Dottie Hamilton</dc:creator>
      <dc:date>2002-01-24T12:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: date script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651958#M46241</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Example please of extension used&lt;BR /&gt;for previous and todays date plus what you tried&lt;BR /&gt;&lt;BR /&gt;You can always touch a file with an mtime of today at 06:00 and then find files older&lt;BR /&gt;and delete them.Then remove touch file.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;         Steve Steel</description>
      <pubDate>Thu, 24 Jan 2002 12:36:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651958#M46241</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2002-01-24T12:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: date script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651959#M46242</link>
      <description>Hi there.&lt;BR /&gt;Try this find statement :&lt;BR /&gt;&lt;BR /&gt;   find /u004/ftp/cash/if/in/cop/archive/ -name icstc_v100_a??????_0??.??-??-??&lt;BR /&gt; -exec rm  {} \;                                                          &lt;BR /&gt;You can replace the last question marks by a parameter, that you can enter.&lt;BR /&gt;Rgds&lt;BR /&gt;Alexander M. Ermes</description>
      <pubDate>Thu, 24 Jan 2002 12:44:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651959#M46242</guid>
      <dc:creator>Alexander M. Ermes</dc:creator>
      <dc:date>2002-01-24T12:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: date script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651960#M46243</link>
      <description>Hi Dottie,&lt;BR /&gt;&lt;BR /&gt;I suppouse that you have files with names like this:&lt;BR /&gt;&lt;BR /&gt;filename.yyyymmdd&lt;BR /&gt;&lt;BR /&gt;If it is you can do a script that keep the today date and rm all the files with an extension minor than today.&lt;BR /&gt;&lt;BR /&gt;Something like this:&lt;BR /&gt;&lt;BR /&gt;cd your directory&lt;BR /&gt;date=$(date +%Y +%b +%d)&lt;BR /&gt;for i in `ls`&lt;BR /&gt;do&lt;BR /&gt;extension=$(echo $i | cut -d. -f2)&lt;BR /&gt;if [ $extension -lt $date ]&lt;BR /&gt;then&lt;BR /&gt;file="\*"+"\."+${extension}&lt;BR /&gt;rm ${file}&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Justo.</description>
      <pubDate>Thu, 24 Jan 2002 12:53:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651960#M46243</guid>
      <dc:creator>Justo Exposito</dc:creator>
      <dc:date>2002-01-24T12:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: date script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651961#M46244</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;today=todays_extension&lt;BR /&gt;find /your_dir -type f|grep -v $today|xargs rm&lt;BR /&gt;&lt;BR /&gt;Will do it if you want to remove all but todays files.&lt;BR /&gt;&lt;BR /&gt;or &lt;BR /&gt;find /yourdir -type f -mtime +1|xargs rm&lt;BR /&gt;&lt;BR /&gt;kill more than 1 day old&lt;BR /&gt;&lt;BR /&gt;          Steve Steel</description>
      <pubDate>Thu, 24 Jan 2002 15:08:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651961#M46244</guid>
      <dc:creator>Steve Steel</dc:creator>
      <dc:date>2002-01-24T15:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: date script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651962#M46245</link>
      <description>Hi Dottie:&lt;BR /&gt;&lt;BR /&gt;I've attached a date script called caljd.sh; this will do almost any date problem; in this case it's overkill but this is my date hammer and every date problem is a nail.&lt;BR /&gt;&lt;BR /&gt;FILENAME=myfile&lt;BR /&gt;SUFFIX=$(caljd.sh -y -s $(caljd.sh -p 1))&lt;BR /&gt;FULLNAME="${FILENAME}.${SUFFIX}"&lt;BR /&gt;This will result in a filename for the previous day of "myfile.20020123".&lt;BR /&gt;&lt;BR /&gt;The inner caljd.sh uses the -p 1 argument to find the julian day 1 day previous. The outer call the converts that julian day into YYYY MM DD (the -y argument) and the -s removes the spaces to yield "YYYYMMDD". Invoke caljd.sh -u for full usage. With this you can skip weekends or holidays, leap years don't matter, or change the number of days previous.&lt;BR /&gt;&lt;BR /&gt;If you start using this script, I think you will use nothing else for a date calculation within a script.&lt;BR /&gt;&lt;BR /&gt;Regards, Clay</description>
      <pubDate>Thu, 24 Jan 2002 15:14:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651962#M46245</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-01-24T15:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: date script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651963#M46246</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;If you have the date in the format: filename.yyyymmdd. You can write your script to make use of the fact that the files are sorted numerically in ls.&lt;BR /&gt;&lt;BR /&gt;This script will remove all filename.* logs except the latest log (ie. today's log):&lt;BR /&gt;==========================================&lt;BR /&gt;#!/sbin/sh&lt;BR /&gt;&lt;BR /&gt;current=`ls filename.*|tail -1`&lt;BR /&gt;&lt;BR /&gt;for file in filename.*&lt;BR /&gt;do&lt;BR /&gt;  if echo $file | grep $current&lt;BR /&gt;then&lt;BR /&gt;  : # today's log, do nothing&lt;BR /&gt;else&lt;BR /&gt;rm $file # remove this log&lt;BR /&gt;fi&lt;BR /&gt;done &lt;BR /&gt;==========================================&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Regards.</description>
      <pubDate>Thu, 24 Jan 2002 15:18:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651963#M46246</guid>
      <dc:creator>Steven Sim Kok Leong</dc:creator>
      <dc:date>2002-01-24T15:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: date script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651964#M46247</link>
      <description>This is what I am trying to use; what have I got wrong?#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;cd /hbo/audittest&lt;BR /&gt;find . -type f -mtime -1 -exec rm -f {} \;&lt;BR /&gt;&lt;BR /&gt;thanks for everyones help&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Jan 2002 16:41:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651964#M46247</guid>
      <dc:creator>Dottie Hamilton</dc:creator>
      <dc:date>2002-01-25T16:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: date script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651965#M46248</link>
      <description>Hi Dottie:&lt;BR /&gt;&lt;BR /&gt;In that case, you need to change your -1 to +1 (older than 1 day). I a little surprised because this stuff has nothing to do with suffixes as your original post indicated.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Jan 2002 16:48:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/date-script/m-p/2651965#M46248</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-01-25T16:48:57Z</dc:date>
    </item>
  </channel>
</rss>

