<?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: Get last months month in alpha? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026711#M97445</link>
    <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;I agree with Peter N. : &lt;BR /&gt;&lt;BR /&gt;If you unconditionally want the previous month without providing a month number as an arguement, then my Perl solution can be reduced to:&lt;BR /&gt;&lt;BR /&gt;# perl -le '@mon=qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);$n=(localtime)[4];$n = $n == 0 ? 11:$n-1;print @mon[$n]'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Mon, 05 Feb 2007 16:43:37 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2007-02-05T16:43:37Z</dc:date>
    <item>
      <title>Get last months month in alpha?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026703#M97437</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Is there a simple way to get last month's month in alpha chars.  For example, this month is "Feb", I need it to output last month "Jan"&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;S.</description>
      <pubDate>Mon, 05 Feb 2007 14:10:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026703#M97437</guid>
      <dc:creator>Coolmar</dc:creator>
      <dc:date>2007-02-05T14:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: Get last months month in alpha?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026704#M97438</link>
      <description>Here's one approach using caljd.sh:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;caljd.sh $(caljd.sh) | read MO DUMMY YEAR&lt;BR /&gt;MON=$(caljd.sh -M -o $(caljd.sh -p 1 ${MO} 1 ${YEAR}))&lt;BR /&gt;echo "Month = ${MON}"&lt;BR /&gt;&lt;BR /&gt;It works by determining the month day and year or the current month, then setting the day of the month to 1 and finding the Julian day of the previous day and then outputting the monthname. Change the "-o" in the last line to "-O" and the full month name will appear -- and full National Language Support works if LANG is set.&lt;BR /&gt;&lt;BR /&gt;Here's caljd.sh; invoke as caljd.sh -u for full usage and examples.&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Feb 2007 15:01:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026704#M97438</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-02-05T15:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: Get last months month in alpha?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026705#M97439</link>
      <description>Here's something that you could try though I would prefer to use caljd.sh&lt;BR /&gt;&lt;BR /&gt;# let x=$(date +"%m")-1&lt;BR /&gt;# cal $(echo $x) $(date +%Y) | awk '{print substr($1,1,3);exit}'</description>
      <pubDate>Mon, 05 Feb 2007 15:19:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026705#M97439</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-02-05T15:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Get last months month in alpha?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026706#M97440</link>
      <description>THIS_MONTH=`date +%b`&lt;BR /&gt;[[ $THIS_MONTH = Jan ]] &amp;amp;&amp;amp; LAST_MONTH=Dec&lt;BR /&gt;[[ $THIS_MONTH = Feb ]] &amp;amp;&amp;amp; LAST_MONTH=Jan&lt;BR /&gt;[[ $THIS_MONTH = Mar ]] &amp;amp;&amp;amp; LAST_MONTH=Feb&lt;BR /&gt;[[ $THIS_MONTH = Apr ]] &amp;amp;&amp;amp; LAST_MONTH=Mar&lt;BR /&gt;..and so on..&lt;BR /&gt;echo Last month was $LAST_MONTH&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-denver</description>
      <pubDate>Mon, 05 Feb 2007 15:45:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026706#M97440</guid>
      <dc:creator>Denver Osborn</dc:creator>
      <dc:date>2007-02-05T15:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: Get last months month in alpha?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026707#M97441</link>
      <description>Hi Coolmar,&lt;BR /&gt;&lt;BR /&gt;I had to do this one with pen and paper first...&lt;BR /&gt;&lt;BR /&gt;$ echo "((($(date +%m)-1)+11)%12)+1"|bc&lt;BR /&gt;&lt;BR /&gt;PCS</description>
      <pubDate>Mon, 05 Feb 2007 15:49:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026707#M97441</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2007-02-05T15:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: Get last months month in alpha?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026708#M97442</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Another:&lt;BR /&gt;&lt;BR /&gt;# perl -le '$m=shift or die;@mon=qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Jan);&lt;BR /&gt;$n = $m == 1 ? 11:$m-2;print @mon[$n]' month_number&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 05 Feb 2007 15:52:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026708#M97442</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-02-05T15:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Get last months month in alpha?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026709#M97443</link>
      <description>Oops... I missed the alpha part with my response above...&lt;BR /&gt;&lt;BR /&gt;set -A mo Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec &amp;amp;&amp;amp; echo ${mo[$(echo "((($(date +%m)-1)+11)%12)"|bc)]}&lt;BR /&gt;&lt;BR /&gt;PCS</description>
      <pubDate>Mon, 05 Feb 2007 16:04:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026709#M97443</guid>
      <dc:creator>spex</dc:creator>
      <dc:date>2007-02-05T16:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: Get last months month in alpha?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026710#M97444</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;a simple ksh array solution:&lt;BR /&gt;&lt;BR /&gt;set -A mo NULL Dec Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec&lt;BR /&gt;print ${mon[$(date +%m)]}&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Mon, 05 Feb 2007 16:18:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026710#M97444</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2007-02-05T16:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Get last months month in alpha?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026711#M97445</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;I agree with Peter N. : &lt;BR /&gt;&lt;BR /&gt;If you unconditionally want the previous month without providing a month number as an arguement, then my Perl solution can be reduced to:&lt;BR /&gt;&lt;BR /&gt;# perl -le '@mon=qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);$n=(localtime)[4];$n = $n == 0 ? 11:$n-1;print @mon[$n]'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 05 Feb 2007 16:43:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026711#M97445</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-02-05T16:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Get last months month in alpha?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026712#M97446</link>
      <description>Along the same lines:&lt;BR /&gt;&lt;BR /&gt;$  perl -e  "print substr(qq(DecJanFebMarAprMayJunJulAugSepOctNov),3*(localtime)[4],3)"&lt;BR /&gt;Jan&lt;BR /&gt;$&lt;BR /&gt;&lt;BR /&gt;Without listing the month names in perl, but much more work :-)&lt;BR /&gt;&lt;BR /&gt;Not useful here, but the principle may help&lt;BR /&gt;&lt;BR /&gt;perl -e  "use Time::Local; @t=localtime; if($t[4]) { $t[4]-- } else {$t[5]--;$t[4]=12} $t=timelocal(@t); $m=(split(" ",scalar l&lt;BR /&gt;ocaltime($t)))[1]; print $m"&lt;BR /&gt;&lt;BR /&gt;Jan&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;use Time::Local;   Find source&lt;BR /&gt;@t=localtime;      Now as array ($sec,$min,$hour,$mday,$mon,$year);&lt;BR /&gt;if($t[4]);         Anything but Jan? &lt;BR /&gt;{ $t[4]-- }        Just decrement the month&lt;BR /&gt;else {&lt;BR /&gt;$t[5]--;$t[4]=12}  Month = 12&lt;BR /&gt;$t=timelocal(@t);  Time in seconds&lt;BR /&gt;$m=(split(" ",     2nd word&lt;BR /&gt;scalar localtime($t)))[1]; Time as text&lt;BR /&gt;print $m"          Finally!&lt;BR /&gt;&lt;BR /&gt;Hein</description>
      <pubDate>Mon, 05 Feb 2007 17:57:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026712#M97446</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-02-05T17:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: Get last months month in alpha?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026713#M97447</link>
      <description>I would prefer a more portable version that leverages "locale LC_TIME" for NLS but that's just me. With caljd.sh you get that for free.</description>
      <pubDate>Mon, 05 Feb 2007 18:27:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026713#M97447</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-02-05T18:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get last months month in alpha?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026714#M97448</link>
      <description>&amp;gt;Clay: I would prefer a more portable version that leverages "locale LC_TIME"&lt;BR /&gt;&lt;BR /&gt;You could take the output from "locale abday", strip the ";" and double quotes and fill your array.&lt;BR /&gt;$ set -A WEEKDAY $(locale abday | sed -e 's/[;"]/ /g')&lt;BR /&gt;$ echo ${WEEKDAY[@]}&lt;BR /&gt;Sun Mon Tue Wed Thu Fri Sat</description>
      <pubDate>Mon, 05 Feb 2007 22:59:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026714#M97448</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-02-05T22:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: Get last months month in alpha?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026715#M97449</link>
      <description>Oops, Coolmar wanted months:&lt;BR /&gt;$ set -A MONTHS $(locale abmon | sed -e 's/[;"]/ /g')&lt;BR /&gt;$ echo ${MONTHS[*]}&lt;BR /&gt;Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec&lt;BR /&gt;&lt;BR /&gt;And to print out last month:&lt;BR /&gt;echo ${MONTHS[($(date +%m)+10)%12]}</description>
      <pubDate>Tue, 06 Feb 2007 06:26:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026715#M97449</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-02-06T06:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Get last months month in alpha?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026716#M97450</link>
      <description>Thanks everyone for all the suggestions!</description>
      <pubDate>Tue, 06 Feb 2007 08:22:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/get-last-months-month-in-alpha/m-p/5026716#M97450</guid>
      <dc:creator>Coolmar</dc:creator>
      <dc:date>2007-02-06T08:22:34Z</dc:date>
    </item>
  </channel>
</rss>

