Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a program which logs like this:

1324218770.7644 INFO etc

What's the best Linux shell program to pipe that through to change the timestamps to a human readable format like Sun 18 Dec 2011 15:32:50 CET?

I can pipe like this through

| cut -f 1 -d\   | awk '{print strftime("%c",$1)}'

for the timestamps only, but how do I maintain the rest of the line?

share|improve this question
up vote 2 down vote accepted

just override $1, then print all line

$ echo '1324218770.7644 INFO etc' | awk '{$1=strftime("%c", $1); print}'
share|improve this answer

I assume that you want the date to be changed inline, printing the rest of the line as well. Try replacing field 1 with the output of strftime().

$ echo "1234218770.7644 INFO etc' | awk '{$1=strftime("%c", $1); print}'
Mon 09 Feb 2009 05:32:50 PM EST INFO etc
share|improve this answer
%s gives me the timestamp - Maybe's its an awk version thing. – Keith Dec 18 '11 at 18:44
Nope. Meant to type %c when I copied from the terminal. Thanks for the catch. – Arcege Dec 18 '11 at 19:28
How did you get the output? Your quotes are kinda messed up in the echo statement. – jaypal singh Dec 19 '11 at 18:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .