<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Getting Yesterdays or Tomorrows Day With Bash Shell Date Command</title> <atom:link href="http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html/feed" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html</link> <description>This is a Linux sys admin journal by Vivek about sys admin work, Linux tips &#38; tricks, hacks, news and more.</description> <lastBuildDate>Fri, 10 Feb 2012 20:37:43 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Dave</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-178981</link> <dc:creator>Dave</dc:creator> <pubDate>Wed, 01 Feb 2012 15:10:58 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-178981</guid> <description>I do not think HP-UX uses the GNU tools, such as /bin/date.
You need more that just bash, presuming you typed &quot;date --date=....&quot;
In other words, &quot;date {dash{dash} date=&quot;
There are many little details like that which make HP-UX annoying.
I am spoiled by Linux.</description> <content:encoded><![CDATA[<p>I do not think HP-UX uses the GNU tools, such as /bin/date.<br
/> You need more that just bash, presuming you typed &#8220;date &#8211;date=&#8230;.&#8221;<br
/> In other words, &#8220;date {dash{dash} date=&#8221;<br
/> There are many little details like that which make HP-UX annoying.<br
/> I am spoiled by Linux.</p> ]]></content:encoded> </item> <item><title>By: Philippe Petrinko</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-178311</link> <dc:creator>Philippe Petrinko</dc:creator> <pubDate>Tue, 10 Jan 2012 10:18:11 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-178311</guid> <description>Hi Chunky,
You post is old, but here is an answer.
Any system can only elaborate data based on what you feed it with, data &amp; algorithm.
A &quot;working day&quot; is a humain professional concern, and, AFAICS, this information is not stored _yet_ in any standard *nix system.
hacked a bit the script with an if loop, if today = Monday, then use yesterday = Friday, else use `date –date=yesterday +%A`, but is not quite an elegant solution.
Elegant or not, system has to store this information before giving it back to you.
FTTOMH, as you want to compare the 2 most recent dump files, another way to do it without this worrying about working days would simply be to select the 2 most recent dump files to compare them, based on modification time.
Nevertheless, on one hand, this involves at least extra coding instead of a simple test, and may be less secure, for instance if you do not check  that every dump went fine.
On the other hand, this algorithm would work in any situation, that is, it would always test the 2 most recent dump files, whatever calendar events, closing days, holidays, whatsoever.
What do you think Chunky?
-- Philippe</description> <content:encoded><![CDATA[<p>Hi Chunky,<br
/> You post is old, but here is an answer.</p><p>Any system can only elaborate data based on what you feed it with, data &amp; algorithm.<br
/> A &#8220;working day&#8221; is a humain professional concern, and, AFAICS, this information is not stored _yet_ in any standard *nix system.</p><p> hacked a bit the script with an if loop, if today = Monday, then use yesterday = Friday, else use `date –date=yesterday +%A`, but is not quite an elegant solution.</p><p>Elegant or not, system has to store this information before giving it back to you.</p><p>FTTOMH, as you want to compare the 2 most recent dump files, another way to do it without this worrying about working days would simply be to select the 2 most recent dump files to compare them, based on modification time.</p><p>Nevertheless, on one hand, this involves at least extra coding instead of a simple test, and may be less secure, for instance if you do not check  that every dump went fine.</p><p>On the other hand, this algorithm would work in any situation, that is, it would always test the 2 most recent dump files, whatever calendar events, closing days, holidays, whatsoever.</p><p>What do you think Chunky?</p><p>&#8211; Philippe</p> ]]></content:encoded> </item> <item><title>By: Philippe Petrinko</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-178291</link> <dc:creator>Philippe Petrinko</dc:creator> <pubDate>Mon, 09 Jan 2012 23:35:06 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-178291</guid> <description>Hi Victor.
I am afraid syntax is unclear to you.
Regarding each token (day, month) syntax may be either using minus sign, either using &quot;ago&quot; word. So that all 4 expressions are referring to one unique date:
date --date &quot;2 months ago 5 days ago&quot;
date --date &quot;- 2 months - 5 days&quot;
date --date &quot;2 months ago - 5 days&quot;
date --date &quot;- 2 months 5 days ago&quot;
Is it clear to you now?
-- Philippe</description> <content:encoded><![CDATA[<p>Hi Victor.</p><p>I am afraid syntax is unclear to you.<br
/> Regarding each token (day, month) syntax may be either using minus sign, either using &#8220;ago&#8221; word. So that all 4 expressions are referring to one unique date:</p><p>date &#8211;date &#8220;2 months ago 5 days ago&#8221;<br
/> date &#8211;date &#8220;- 2 months &#8211; 5 days&#8221;<br
/> date &#8211;date &#8220;2 months ago &#8211; 5 days&#8221;<br
/> date &#8211;date &#8220;- 2 months 5 days ago&#8221;</p><p>Is it clear to you now?</p><p>&#8211; Philippe</p> ]]></content:encoded> </item> <item><title>By: victor</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-178283</link> <dc:creator>victor</dc:creator> <pubDate>Mon, 09 Jan 2012 20:03:09 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-178283</guid> <description>It does work but it should look like:
date --date &quot;-2 months 5 days ago&quot;</description> <content:encoded><![CDATA[<p>It does work but it should look like:<br
/> date &#8211;date &#8220;-2 months 5 days ago&#8221;</p> ]]></content:encoded> </item> <item><title>By: Chunky</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-174737</link> <dc:creator>Chunky</dc:creator> <pubDate>Mon, 10 Oct 2011 14:28:15 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-174737</guid> <description>Hi all,
I am having a script to check filesize&#039;s difference between two consecutive days dumps. The DB dumps are created every WORKING day (Monday-Friday) and they all have the same name + the full name day of the week, i.e. dumpFile.Monday.dump, dumpFile.Tuesday.dump ... dumpFile.Friday.dump.
In my script I try to use &lt;em&gt;`date +%A`&lt;/em&gt; for today and &lt;em&gt;`date --date=yesterday +%A`&lt;/em&gt; for yesterday, however this (obviously) doesn&#039;t work for Monday, when I get yesterday as being Sunday, whereas I want Friday.
I hacked a bit the script with an if loop, if today = Monday, then use yesterday = Friday, else use &lt;em&gt;`date --date=yesterday +%A`&lt;/em&gt;, but is not quite an elegant solution.
I wonder if there&#039;s a way that on any given date, to be able to get previous WORKING day.
Cheers</description> <content:encoded><![CDATA[<p>Hi all,</p><p>I am having a script to check filesize&#8217;s difference between two consecutive days dumps. The DB dumps are created every WORKING day (Monday-Friday) and they all have the same name + the full name day of the week, i.e. dumpFile.Monday.dump, dumpFile.Tuesday.dump &#8230; dumpFile.Friday.dump.</p><p>In my script I try to use <em>`date +%A`</em> for today and <em>`date &#8211;date=yesterday +%A`</em> for yesterday, however this (obviously) doesn&#8217;t work for Monday, when I get yesterday as being Sunday, whereas I want Friday.</p><p>I hacked a bit the script with an if loop, if today = Monday, then use yesterday = Friday, else use <em>`date &#8211;date=yesterday +%A`</em>, but is not quite an elegant solution.</p><p>I wonder if there&#8217;s a way that on any given date, to be able to get previous WORKING day.</p><p>Cheers</p> ]]></content:encoded> </item> <item><title>By: Vivek Gite</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-171947</link> <dc:creator>Vivek Gite</dc:creator> <pubDate>Wed, 15 Jun 2011 00:35:05 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-171947</guid> <description>@Nico / Philippe,
This article has been updated with information on the date command with additional examples.</description> <content:encoded><![CDATA[<p>@Nico / Philippe,</p><p>This article has been updated with information on the date command with additional examples.</p> ]]></content:encoded> </item> <item><title>By: Philippe Petrinko</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-171939</link> <dc:creator>Philippe Petrinko</dc:creator> <pubDate>Tue, 14 Jun 2011 15:02:38 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-171939</guid> <description>Yes Rigth Nico.
Vivek should amend this one, right Vivek ?</description> <content:encoded><![CDATA[<p>Yes Rigth Nico.</p><p>Vivek should amend this one, right Vivek ?</p> ]]></content:encoded> </item> <item><title>By: rani</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-171933</link> <dc:creator>rani</dc:creator> <pubDate>Tue, 14 Jun 2011 11:57:44 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-171933</guid> <description>we are using this command in our pull script to get day-1 data.
vYdy_yyyy_mm_dd=`date --d=&#039;1 days ago&#039; +&quot;%Y-%m-%d&quot;`
But i want data from 2010-08-1 to 2010-05-19 at a time.Could you please help me out in changing the command.
vYdy_yyyy_mm_dd=`date --d=&#039;1 days ago&#039; +&quot;%Y-%m-%d&quot;`</description> <content:encoded><![CDATA[<p>we are using this command in our pull script to get day-1 data.<br
/> vYdy_yyyy_mm_dd=`date &#8211;d=&#8217;1 days ago&#8217; +&#8221;%Y-%m-%d&#8221;`<br
/> But i want data from 2010-08-1 to 2010-05-19 at a time.Could you please help me out in changing the command.<br
/> vYdy_yyyy_mm_dd=`date &#8211;d=&#8217;1 days ago&#8217; +&#8221;%Y-%m-%d&#8221;`</p> ]]></content:encoded> </item> <item><title>By: jay</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-171916</link> <dc:creator>jay</dc:creator> <pubDate>Mon, 13 Jun 2011 22:26:45 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-171916</guid> <description>for ((i=&quot;2010-12-01&quot;; i&lt;=&quot;2011-06-14&quot;; $currentDateTS+=86400))
do
echo $i&quot;\n&quot;
done
i know something is not right here please advice.</description> <content:encoded><![CDATA[<p>for ((i=&#8221;2010-12-01&#8243;; i&lt;=&quot;2011-06-14&quot;; $currentDateTS+=86400))<br
/> do<br
/> echo $i&quot;\n&quot;<br
/> done</p><p>i know something is not right here please advice.</p> ]]></content:encoded> </item> <item><title>By: jay</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-171915</link> <dc:creator>jay</dc:creator> <pubDate>Mon, 13 Jun 2011 21:57:06 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-171915</guid> <description>hello -
I am looking for some ideas to print out dates in between 2 dates in YYYY-mm-dd format in unix.
any advice is appreciated.
thanks</description> <content:encoded><![CDATA[<p>hello &#8211;</p><p>I am looking for some ideas to print out dates in between 2 dates in YYYY-mm-dd format in unix.</p><p>any advice is appreciated.</p><p>thanks</p> ]]></content:encoded> </item> <item><title>By: Nico</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-171801</link> <dc:creator>Nico</dc:creator> <pubDate>Wed, 08 Jun 2011 13:05:08 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-171801</guid> <description>You have a little flaw in there:
&lt;pre&gt;date --date &quot;2 months 5 days ago&quot;&lt;/pre&gt;
doesn&#039;t return the date two months and five days ago but rather the date which was five days before the date which will be in two months. It tells date something like &quot;plus 2 months minus 5 days&quot;.
Of course, this might be what you wanted. But to be corresponding to your descripten, it would have to be
&lt;pre&gt;date --date &quot;2 months ago 5 days ago&quot;&lt;/pre&gt;</description> <content:encoded><![CDATA[<p>You have a little flaw in there:</p><pre>date --date "2 months 5 days ago"</pre><p>doesn&#8217;t return the date two months and five days ago but rather the date which was five days before the date which will be in two months. It tells date something like &#8220;plus 2 months minus 5 days&#8221;.</p><p>Of course, this might be what you wanted. But to be corresponding to your descripten, it would have to be</p><pre>date --date "2 months ago 5 days ago"</pre>]]></content:encoded> </item> <item><title>By: seldi</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-171744</link> <dc:creator>seldi</dc:creator> <pubDate>Sat, 04 Jun 2011 08:34:58 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-171744</guid> <description>It was very helpfully for me.
Thanks</description> <content:encoded><![CDATA[<p>It was very helpfully for me.<br
/> Thanks</p> ]]></content:encoded> </item> <item><title>By: Geneyo</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-171708</link> <dc:creator>Geneyo</dc:creator> <pubDate>Thu, 02 Jun 2011 19:27:14 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-171708</guid> <description>I am having similar error on HP.  How did you resovle your problem?</description> <content:encoded><![CDATA[<p>I am having similar error on HP.  How did you resovle your problem?</p> ]]></content:encoded> </item> <item><title>By: Skyblaster</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-170306</link> <dc:creator>Skyblaster</dc:creator> <pubDate>Thu, 24 Mar 2011 15:16:59 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-170306</guid> <description>Hello guys,
(i missed the TODAYR (is day number from 1-7) in my prev email)
TODAY=`date +%d-%m-%Y`
TODAYR=`date +%u`
if [ ${TODAYR} -eq 5 ]
then
DD2=`TZ=&quot;GMT-72&quot; date +&#039;%d&#039;`
else
DD2=`TZ=&quot;GMT-24&quot; date +&#039;%d&#039;`
fi
if [ ${DD} -gt ${DD2} ]
then</description> <content:encoded><![CDATA[<p>Hello guys,</p><p>(i missed the TODAYR (is day number from 1-7) in my prev email)<br
/> TODAY=`date +%d-%m-%Y`<br
/> TODAYR=`date +%u`<br
/> if [ ${TODAYR} -eq 5 ]<br
/> then<br
/> DD2=`TZ=&#8221;GMT-72&#8243; date +&#8217;%d&#8217;`<br
/> else<br
/> DD2=`TZ=&#8221;GMT-24&#8243; date +&#8217;%d&#8217;`<br
/> fi<br
/> if [ ${DD} -gt ${DD2} ]<br
/> then</p> ]]></content:encoded> </item> <item><title>By: Skyblaster</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-170305</link> <dc:creator>Skyblaster</dc:creator> <pubDate>Thu, 24 Mar 2011 15:14:26 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-170305</guid> <description>Hello guys,
Here is a nice one it calculate the latest working day of the month maybe it&#039;s usefull
TODAY=`date +%d-%m-%Y`
if [ ${TODAYR} -eq 5 ]
then
DD2=`TZ=&quot;GMT-72&quot; date +&#039;%d&#039;`
else
DD2=`TZ=&quot;GMT-24&quot; date +&#039;%d&#039;`
fi
if [ ${DD} -gt ${DD2} ]
then
another script on the latest work day of the month
else
exit</description> <content:encoded><![CDATA[<p>Hello guys,</p><p>Here is a nice one it calculate the latest working day of the month maybe it&#8217;s usefull<br
/> TODAY=`date +%d-%m-%Y`<br
/> if [ ${TODAYR} -eq 5 ]<br
/> then<br
/> DD2=`TZ=&#8221;GMT-72&#8243; date +&#8217;%d&#8217;`<br
/> else<br
/> DD2=`TZ=&#8221;GMT-24&#8243; date +&#8217;%d&#8217;`<br
/> fi<br
/> if [ ${DD} -gt ${DD2} ]<br
/> then<br
/> another script on the latest work day of the month</p><p>else</p><p>exit</p> ]]></content:encoded> </item> <item><title>By: bob</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-169342</link> <dc:creator>bob</dc:creator> <pubDate>Tue, 01 Mar 2011 00:11:57 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-169342</guid> <description>doesn&#039;t work on Mac OS X</description> <content:encoded><![CDATA[<p>doesn&#8217;t work on Mac OS X</p> ]]></content:encoded> </item> <item><title>By: Reynold P J</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-160813</link> <dc:creator>Reynold P J</dc:creator> <pubDate>Sat, 06 Nov 2010 23:34:52 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-160813</guid> <description>I usually find really helpful articles in this site....
Keep up the good work:)</description> <content:encoded><![CDATA[<p>I usually find really helpful articles in this site&#8230;.<br
/> Keep up the good work:)</p> ]]></content:encoded> </item> <item><title>By: Rajesh</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-159812</link> <dc:creator>Rajesh</dc:creator> <pubDate>Thu, 23 Sep 2010 15:42:30 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-159812</guid> <description>Is there any way to caculate the current staturday&#039;s date based on the input date passed not from the system date?
Please let me know
Thanks,
Rajesh</description> <content:encoded><![CDATA[<p>Is there any way to caculate the current staturday&#8217;s date based on the input date passed not from the system date?</p><p>Please let me know<br
/> Thanks,<br
/> Rajesh</p> ]]></content:encoded> </item> <item><title>By: Philippe Petrinko</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-159676</link> <dc:creator>Philippe Petrinko</dc:creator> <pubDate>Fri, 17 Sep 2010 16:03:54 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-159676</guid> <description>@Andrew &amp; @Sourav
May be wordpress word entry has eaten some of your characters,
here is an equivalent rephrase of what you gave,
to print last day of current month on GNU/BASH shell
&lt;code&gt;
date --date &quot;next month - $(date +%d) day&quot;
&lt;/code&gt;</description> <content:encoded><![CDATA[<p>@Andrew &amp; @Sourav</p><p>May be wordpress word entry has eaten some of your characters,<br
/> here is an equivalent rephrase of what you gave,<br
/> to print last day of current month on GNU/BASH shell<br
/> <code><br
/> date --date "next month - $(date +%d) day"<br
/> </code></p> ]]></content:encoded> </item> <item><title>By: joi sagum</title><link>http://www.cyberciti.biz/tips/linux-unix-get-yesterdays-tomorrows-date.html#comment-159590</link> <dc:creator>joi sagum</dc:creator> <pubDate>Mon, 13 Sep 2010 02:42:53 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/getting-yesterdays-or-tomorrows-day-with-shell-date-command.html#comment-159590</guid> <description>How this this done in AIX?</description> <content:encoded><![CDATA[<p>How this this done in AIX?</p> ]]></content:encoded> </item> </channel> </rss>
