awk is better for these stuff, if acceptable:
awk -F, '{x=$1;sub(/.*=/,"",$1);sub(/=.*/,strftime("=%Y-%m-%d %H:%M:%S",$1),x);$1=x;}1' OFS=, file
A sample result:
$ cat file
timestamp=1356431101, entity=xxx, event: xxxxxx
timestamp=1354770380, entity=xxx, event: xxxxxx
On running the command:
$ awk -F, '{x=$1;sub(/.*=/,"",$1);sub(/=.*/,strftime("=%Y-%m-%d %H:%M:%S",$1),x);$1=x;}1' OFS=, file
timestamp=2012-12-25 15:55:01, entity=xxx, event: xxxxxx
timestamp=2012-12-06 10:36:20, entity=xxx, event: xxxxxx
The first sub
command extracts the timestamp. The second using the strftime
replaces the timestamp with the date and time. 1
is used to print every line.