<?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 to subtract time from $date within a script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655722#M677151</link>
    <description>Hi James,&lt;BR /&gt;&lt;BR /&gt;sorry I should have said it is korn shell script. Can I use localtime with that?&lt;BR /&gt;&lt;BR /&gt;My script is like this &lt;BR /&gt;&lt;BR /&gt;myFile="/fnsw/local/logs/elogs/elog"$(date +%Y%m%d);&lt;BR /&gt;serious=$(find $myFile -exec grep -l 'OPERATOR INTERVENTION' {} \;);&lt;BR /&gt;&lt;BR /&gt;        if [ -n "$serious" ];   then&lt;BR /&gt;        mailx -s "Disk Message in FileNet elog" $MLIST &amp;lt; $myFile;&lt;BR /&gt;        fi&lt;BR /&gt;</description>
    <pubDate>Thu, 01 Jul 2010 13:15:41 GMT</pubDate>
    <dc:creator>Noreen Merrick_1</dc:creator>
    <dc:date>2010-07-01T13:15:41Z</dc:date>
    <item>
      <title>how to subtract time from $date within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655720#M677149</link>
      <description>Hi I have a script which searches through a log file for certain words. However my log file always has yesterday's date i.e. one day previous &lt;BR /&gt;&lt;BR /&gt;I have log file like the following but of course this will only look for today's date.&lt;BR /&gt;&lt;BR /&gt;myFile="/fnsw/local/logs/elogs/elog"$(date +%Y%m%d);&lt;BR /&gt;&lt;BR /&gt;Can i amend this in some way to look for logs with yesterday's date. I have seen -a option on man date but is that only when setting the date?</description>
      <pubDate>Thu, 01 Jul 2010 13:00:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655720#M677149</guid>
      <dc:creator>Noreen Merrick_1</dc:creator>
      <dc:date>2010-07-01T13:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to subtract time from $date within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655721#M677150</link>
      <description>Hi Noreen:&lt;BR /&gt;&lt;BR /&gt;Use Perl;&lt;BR /&gt;&lt;BR /&gt;# perl -MPOSIX -le 'print strftime "%m/%d/%Y",localtime(time-86400)'&lt;BR /&gt;&lt;BR /&gt;...or capture the value like:&lt;BR /&gt;&lt;BR /&gt;# DATE=$(perl -MPOSIX -le 'print strftime "%m/%d/%Y",localtime(time-86400)')&lt;BR /&gt;&lt;BR /&gt;Of course, 86400 seconds is one-day (24*60*60).&lt;BR /&gt;&lt;BR /&gt;You can create any date format you want using the same formatting directives you would use with 'date(1)'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Jul 2010 13:11:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655721#M677150</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-07-01T13:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to subtract time from $date within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655722#M677151</link>
      <description>Hi James,&lt;BR /&gt;&lt;BR /&gt;sorry I should have said it is korn shell script. Can I use localtime with that?&lt;BR /&gt;&lt;BR /&gt;My script is like this &lt;BR /&gt;&lt;BR /&gt;myFile="/fnsw/local/logs/elogs/elog"$(date +%Y%m%d);&lt;BR /&gt;serious=$(find $myFile -exec grep -l 'OPERATOR INTERVENTION' {} \;);&lt;BR /&gt;&lt;BR /&gt;        if [ -n "$serious" ];   then&lt;BR /&gt;        mailx -s "Disk Message in FileNet elog" $MLIST &amp;lt; $myFile;&lt;BR /&gt;        fi&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Jul 2010 13:15:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655722#M677151</guid>
      <dc:creator>Noreen Merrick_1</dc:creator>
      <dc:date>2010-07-01T13:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to subtract time from $date within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655723#M677152</link>
      <description>Hi (again) Noreen:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; sorry I should have said it is korn shell script. Can I use localtime with that?&lt;BR /&gt;&lt;BR /&gt;You can use Perl to create a variable that represents yesterday's date.  Your shell script simply invokes this tiny Perl snippet.&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;DATE=$(perl -MPOSIX -le 'print strftime "%m/%d/%Y",localtime(time-86400)')&lt;BR /&gt;myFile="/fnsw/local/logs/elogs/elog${DATE}"&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;The option you are thinking about is no doubt the GNU 'date' command.  HP-UX lacks that functionality and we need to leverage Perl.  This is no different than writing a shell script with snippets of 'sed' or 'awk'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Jul 2010 13:20:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655723#M677152</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-07-01T13:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to subtract time from $date within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655724#M677153</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Oh, you want a year-month-day format, so re-arrange (as I said you could) the formatting directives.  You want:&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;DATE=$(perl -MPOSIX -le 'print strftime "%Y/%m/%d",localtime(time-86400)')&lt;BR /&gt;myFile="/fnsw/local/logs/elogs/elog${DATE}"&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 01 Jul 2010 13:26:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655724#M677153</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-07-01T13:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to subtract time from $date within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655725#M677154</link>
      <description>I have no perl installed</description>
      <pubDate>Thu, 01 Jul 2010 13:31:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655725#M677154</guid>
      <dc:creator>Noreen Merrick_1</dc:creator>
      <dc:date>2010-07-01T13:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to subtract time from $date within a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655726#M677155</link>
      <description>Hi (again) Noreen:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I have no perl installed&lt;BR /&gt;&lt;BR /&gt;I find that very hard to believe.  What is your operating system -- post up 'uname -a'.&lt;BR /&gt;&lt;BR /&gt;Perhaps the perl binary isn't in your PATH.  Look for 'perl':&lt;BR /&gt;&lt;BR /&gt;# find /usr /opt -name perl&lt;BR /&gt;&lt;BR /&gt;If this is HP-UX you should find:&lt;BR /&gt;&lt;BR /&gt;/opt/perl_32/bin/perl&lt;BR /&gt;/opt/perl_64/bin/perl&lt;BR /&gt;&lt;BR /&gt;Create a symlink from '/usr/bin/perl' to either of the above.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Jul 2010 13:37:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/how-to-subtract-time-from-date-within-a-script/m-p/4655726#M677155</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-07-01T13:37:58Z</dc:date>
    </item>
  </channel>
</rss>

