Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Hi i want to convert UNIX date to normal date (YYYY-MM-DD)

22222,0,0,0,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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
117 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...