From owner-freebsd-questions@FreeBSD.ORG Fri Apr 16 09:18:02 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5BA8316A4CE for ; Fri, 16 Apr 2004 09:18:02 -0700 (PDT) Received: from smtp.infracaninophile.co.uk (happy-idiot-talk.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id DDDEA43D3F for ; Fri, 16 Apr 2004 09:18:00 -0700 (PDT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) i3GGHoJ7058470 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 16 Apr 2004 17:17:50 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id i3GGHojB058455; Fri, 16 Apr 2004 17:17:50 +0100 (BST) (envelope-from matthew) Date: Fri, 16 Apr 2004 17:17:50 +0100 From: Matthew Seaman To: JJB Message-ID: <20040416161750.GA33400@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , JJB , Erik Trulsson , "freebsd-questions@FreeBSD. ORG" References: <20040416050053.GA52342@falcon.midgard.homeip.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="envbJBWh7q8WU6mo" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i X-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on happy-idiot-talk.infracaninophile.co.uk X-Virus-Scanned: clamd / ClamAV version devel-20040407, clamav-milter version 0.70g cc: "freebsd-questions@FreeBSD. ORG" Subject: Re: timezone command X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Apr 2004 16:18:02 -0000 --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--