Hi,
I have logfile like this :
Actually the format is date format :
yyyymmddHHMMSS
and i want the log become this format
yyyy-mm-dd HH:MM:SS
for example
2009-07-19 11:46:52
Can somebody help me ?
Thanks in advance
Hi,
I have logfile like this :
Actually the format is date format :
yyyymmddHHMMSS
and i want the log become this format
yyyy-mm-dd HH:MM:SS
for example
2009-07-19 11:46:52
Can somebody help me ?
Thanks in advance
try..
awk '{print substr($1,1,4)"-"substr($1,5,2)"-"substr($1,7,2),substr($1,9,2)":"substr($1,11,2)":"substr($1,13,2)}' file
One way to do it in perl:
$
$ perl -ne '@x=unpack("A4 A2 A2 A2 A2 A2",$_); printf("%s-%s-%s %s:%s:%s\n",$x[0],$x[1],$x[2],$x[3],$x[4],$x[5])' logfile.txt
2009-05-13 12:34:15
2009-07-19 14:01:36
2009-07-12 09:23:40
2009-07-25 07:49:55
2009-07-25 07:49:56
2009-07-25 07:49:55
2009-07-25 07:49:57
2009-07-19 10:56:25
2009-07-12 09:23:40
2009-07-12 09:23:40
2009-07-24 19:11:30
2009-07-19 11:09:32
2009-07-12 09:23:40
2009-07-25 13:35:51
2009-07-19 12:26:39
2009-07-12 09:23:40
2009-07-25 14:22:50
2009-07-24 22:31:47
2009-07-19 11:46:52
$
tyler_durden
sed line will be shorter:
sed 's/\(....\)\(..\)\(..\)\(..\)\(..\)\(..\)/\1-\2-\3 \4:\5:\6/' logfile.txt