summaryrefslogtreecommitdiff
path: root/ts
blob: 42a1ce4e37dcfb80212882990dea8e87be85f48b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl

=head1 NAME

ts - timestamp input

=head1 SYNOPSIS

ts [format]

=head1 DESCRIPTION

ts adds a timestamp to the beginning of each line of input

The optional format parameter controls how the timestamp is formatted,
as used by L<strftime(3)>. The default format is "%H:%M:%S".

=head1 AUTHOR

Copyright 2006 by Joey Hess <joey@kitenet.net>

Licensed under the GNU GPL.

=cut

use warnings;
use strict;
use POSIX q{strftime};

my $format="%H:%M:%S";
$format=shift if @ARGV;

$|=1;

while (<>) {
	print strftime($format, localtime)." ".$_;
}