Date: Fri, 16 Apr 2004 17:17:50 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: JJB <Barbish3@adelphia.net> Cc: "freebsd-questions@FreeBSD. ORG" <freebsd-questions@freebsd.org> Subject: Re: timezone command Message-ID: <20040416161750.GA33400@happy-idiot-talk.infracaninophile.co.uk> In-Reply-To: <MIEPLLIBMLEEABPDBIEGGEBBFMAA.Barbish3@adelphia.net> References: <20040416050053.GA52342@falcon.midgard.homeip.net> <MIEPLLIBMLEEABPDBIEGGEBBFMAA.Barbish3@adelphia.net>
next in thread | previous in thread | raw e-mail | index | archive | help
--envbJBWh7q8WU6mo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 16, 2004 at 11:48:11AM -0400, JJB wrote: > Yes that is close enough for an starting point, thank you. >=20 > I need $timezone to hold the time zone in this format -00:00 > The command date +%z will give it as -0000 >=20 > I know nothing about writing perl scripts. >=20 > Can somebody show me how to add the : in the output > of the date command in the simple following script? >=20 > The cat statement is just so I can see results are correct. >=20 >=20 > #!/usr/bin/perl > $timezone=3Ddate +%z; > cat $timezone You can do it very easily with perl: #!/usr/bin/perl -w use POSIX (strftime); ($d =3D strftime("%z", localtime)) =3D~ s/(\d\d)(\d\d)/$1:$2/; print "$d\n"; but it's probably a bit too heavyweight to use perl to format the string if you aren't already writing a whole script in perl. Instead, try: date +%z | sed -e 's,\([0-9][0-9]\)\([0-9][0-9]\),\1:\2,' Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way PGP: http://www.infracaninophile.co.uk/pgpkey Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK --envbJBWh7q8WU6mo Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAgAcudtESqEQa7a0RAofKAJ9WAKFPgIXFJf+Uid0AhzmS55oHOgCbBeCa Jy710bZNafudXpjefxszsLk= =ivNt -----END PGP SIGNATURE----- --envbJBWh7q8WU6mo--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040416161750.GA33400>