timezone command

Shaun Friedle shaun at insipidity.co.uk
Fri Apr 16 14:25:40 PDT 2004


On Fri, 2004-04-16 at 17:17, Matthew Seaman wrote:
> 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


Oops, didn't notice this because it was in a different thread. Well now
you  have two Perl solutions :)
-- 
Shaun Friedle



More information about the freebsd-questions mailing list