Reputation: 24288
cat test.txt |
awk 'BEGIN { FS = "\t" } ;{ print $44=strftime("%d %b %Y",$44) "\t" $44 }'
I have received:
31 12 1969 2012-09-27
But I have expected:
27 Sep 2012 2012-09-27
Where is the error? Thanks.
Upvotes: 3
Views: 7113
Reputation: 195239
if you really want to convert the format with awk build-in functions, this example may help you:
kent$ echo "2012-09-27" |awk '{t=$0;gsub("-"," ",t);print strftime("%d %b %Y", mktime(t" 00 00 00"))}'
27 Sep 2012
read the description of following functions in man page:
mktime(datespec)
strftime([format [, timestamp[, utc-flag]]])
edit try to fix you old command, but no input file, cannot test it...
awk 'BEGIN {FS=OFS="\t"}{t=$44;gsub("-"," ",t); print strftime("%d %b %Y", mktime(t" 00 00 00")),$44}' test.txt
Upvotes: 5