I have a file that contains dates and lat longs and I want to convert the dates that are in UTC to unix time. I decided to use the unix date function within an awk script to do this. I tried:
awk 'BEGIN {t=$3; c="date -j -f %Y%j%H%M%S "t" +%s"; c|getline; close( c ); print $1, $2, c; }' test.txt
where t
is the third row in my file and is in the format 2014182120311. I am new to awk/scripting and not sure if it is possible to imbed an awk variable into a unix command inside an awk line.
When I run the script I get the error:
usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
[-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
So I think I am not defining "t" properly. Any help is much appreciated!
On a side note- I have tried mktime and the other awk time functions but they do not work for me I believe because I do not have gawk.