Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Nov 2007 07:45:43 +0200
From:      Jonathan McKeown <jonathan+freebsd-questions@hst.org.za>
To:        freebsd-questions@freebsd.org
Subject:   Re: shell programming
Message-ID:  <200711100745.43287.jonathan%2Bfreebsd-questions@hst.org.za>
In-Reply-To: <7EA6F842-7C0D-4EFC-BF4D-DD83B0524597@gmail.com>
References:  <47349D10.20709@ourweb.net> <7EA6F842-7C0D-4EFC-BF4D-DD83B0524597@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 09 November 2007 20:02, Eric Crist wrote:
> On Nov 9, 2007, at 11:46 AM, Bill Banks wrote:
> > I'm  writing a backup script. I need to get the day of the week into
> > a variable. How can I do it?
>
> Well, it depends on what you're using.  If you're using sh, see `man
> date`.  If you're using perl, it's quite complicated.

Not really:

use POSIX 'strftime';
my $day_of_week = strftime '%A', localtime;

POSIX has always been a core module. To see this in action from a commandline,

perl -MPOSIX=strftime -le 'print strftime q/%A/, localtime'

Jonathan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200711100745.43287.jonathan%2Bfreebsd-questions>