Hi i want to convert UNIX date to normal date (YYYY-MM-DD)
22222,0,0,开发者_如何学JAVA0,14387
33333,0,0,0,14170
44444,0,0,0,14244
55555,0,0,0,14190
66666,0,0,0,14528
77777,0,0,0,14200
88888,0,0,0,0
99999,0,0,0,0
here 5th column represents UNIX date
i want to convert into
22222,0,0,0,2009-05-23
and similarly remaining rows
can any body help me
A simple awk script ought to do it
awk -F, 'BEGIN{OFS=","} { print $1,$2,$3,$4,strftime("%Y-%m-%d",$5) }' myFile.txt
Cheers.
EDIT:
You're not using unix timestamps, but I checked your data, and it appears you're using days since the epoch, so here goes:
awk -F, 'BEGIN{OFS=","} { print $1,$2,$3,$4,strftime("%Y-%m-%d",$5*86400) }' myFile.txt
精彩评论