Timestamp to Epoch in a CSV file with GAWK

后端 未结 2 1275
抹茶落季
抹茶落季 2020-12-18 05:07

Looking to convert human readable timestamps to epoch/Unix time within a CSV file using GAWK in preparation for loading into a MySQL DB.

Data Example:



        
2条回答
  •  春和景丽
    2020-12-18 05:24

    You can convert date to epoch with this snippet :

    $ date -d 'Tuesday, November 26 12:17 PM' +%s
    1385464620
    

    So finally :

    awk -F";" '{system("date -d \""$6"\" '+%s'")}' file
    

    Thanks @Keiron for the snippet.

提交回复
热议问题