Skip to content

Instantly share code, notes, and snippets.

@xandkar
Created August 29, 2012 21:30
Show Gist options
  • Save xandkar/3519226 to your computer and use it in GitHub Desktop.
Save xandkar/3519226 to your computer and use it in GitHub Desktop.
AWK dates lookup table
awk 'BEGIN{
m=split("Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec",d,"|")
for(o=1;o<=m;o++){
date[d[o]]=sprintf("%02d",o)
}
}
{
gsub(/\[/,"",$4); gsub(":","/",$4); gsub(/\]/,"",$5)
n=split($4, DATE,"/")
day=DATE[1]
mth=DATE[2]
year=DATE[3]
hr=DATE[4]
min=DATE[5]
sec=DATE[6]
MKTIME= mktime(year" "date[mth]" "day" "hr" "min" "sec)
print $1,MKTIME
}' file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment