[ale] Linux shell process

James Sumners james.sumners at gmail.com
Mon Mar 19 19:38:21 EDT 2012


On Arch Linux, it's sort of in the man page:

"-d, --date=STRING
              display time described by STRING, not `now'
...
...
DATE STRING
       The  --date=STRING  is  a  mostly free format human readable
date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29
       16:21:42" or even "next Thursday".  A date string may contain
items indicating calendar date, time of  day,  time  zone,  day  of
       week,  relative time, relative date, and numbers.  An empty
string indicates the beginning of the day.  The date string format is
       more complex than is easily documented here but is fully
described in the info documentation."

Which leads to:

$ date -d "5 days ago"
Wed Mar 14 19:37:54 EDT 2012

Interestingly, on OS 10.7:

[jsumners at Morla] ~/ $ date -h
date: illegal option -- h
usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
[jsumners at Morla] ~/ $ date -v -5d
Wed Mar 14 19:32:43 EDT 2012



On Mon, Mar 19, 2012 at 15:10, Michael H. Warfield <mhw at wittsend.com> wrote:
> On Mon, 2012-03-19 at 16:03 +0000, Lightner, Jeff wrote:
>> I use cal to cheat at date math.  With grep and wc you can figure out many things more simply than with more esoteric methods.
>
> For shell scripts, I use "date" for date math.
>
> You gotta really get into the info stuff but the things you can do with
> the date --date option are simply amazing...
>
> [mhw at canyon ~]$ date --date=yesterday
> Sun Mar 18 15:05:34 EDT 2012
> [mhw at canyon ~]$ date --date="today - 1 month"
> Sun Feb 19 14:05:41 EST 2012
> [mhw at canyon ~]$ date --date="today - 3 weeks"
> Mon Feb 27 14:05:51 EST 2012
> [mhw at canyon ~]$ date --date="Mon Feb 27 14:05:51 EST 2012 - 3 weeks"
> Mon Feb  6 14:05:51 EST 2012
> [mhw at canyon ~]$ date --date="Mon Feb 27 14:05:51 EST 2012 - 3 weeks - 6 hours"
> Mon Feb  6 08:05:51 EST 2012
>
> It's documented in the info pages for date but not in the man pages (a
> little too complex for man, I'm afraid).
>
> Regards,
> Mike


-- 
James Sumners
http://james.roomfullofmirrors.com/

"All governments suffer a recurring problem: Power attracts
pathological personalities. It is not that power corrupts but that it
is magnetic to the corruptible. Such people have a tendency to become
drunk on violence, a condition to which they are quickly addicted."

Missionaria Protectiva, Text QIV (decto)
CH:D 59



More information about the Ale mailing list