On Fri, Apr 16, 2004 at 11:48:11AM -0400, JJB wrote: > Yes that is close enough for an starting point, thank you. > > I need $timezone to hold the time zone in this format -00:00 > The command date +%z will give it as -0000 > > I know nothing about writing perl scripts. > > Can somebody show me how to add the : in the output > of the date command in the simple following script? > > The cat statement is just so I can see results are correct. > > > #!/usr/bin/perl > $timezone=date +%z; > cat $timezone
You can do it very easily with perl:
#!/usr/bin/perl -w
use POSIX (strftime);
($d = strftime("%z", localtime)) =~ 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
--
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
pgp00000.pgp
Description: PGP signature
