Skip to content

Instantly share code, notes, and snippets.

@jkoppe
Created July 20, 2012 18:44
Show Gist options
  • Save jkoppe/3152499 to your computer and use it in GitHub Desktop.
Save jkoppe/3152499 to your computer and use it in GitHub Desktop.
add timestamps with perl
jkoppe@localhost in ~ at 2012-07-20 13:43:47
--> echo something
something
jkoppe@localhost in ~ at 2012-07-20 13:43:50
--> echo something | timestamp
Fri Jul 20 13:43:54 2012 something
jkoppe@localhost in ~ at 2012-07-20 13:43:54
-->
#!/usr/bin/perl
# Don't buffer output
$| = 1;
# Prefix a timestamp to our input lines
while (<>) {
print scalar localtime, " $_" ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment