Change format of a field using awk
I have a very large file with more than 500,000 lines of dated events.The first field contains the date/time in the following format:
20120727-files.files:20120727090044
Where the first 8 numbers represent yyyymmdd. The last set of numbers represent yyyy/mm/dd/hh:mm:ss
I would like to change the value of the first field to:
YYYY-MM-DD HH:MM:SS
solution:
awk -F":" '{
print substr($2,0,4)"-"substr($2,5,2)"-"
substr($2,7,2)" "substr($2,9,2)":"
substr($2,11,2)":"substr($2,13,2)
}' your_file
0 comments: