I have a CSV where the first column has a string that represents datetime. I would like to add an extra column with that datetime converted to epoch.I tried the following:  awk -F , 'BEGIN{ OFS=, } {$14=$(date -jf %m/%d/%Y %H:%M:%S %p $1 +%s); print} mycsv.csv > test  I get:  awk: illegal field $(0%m/%d/%Y %H:%M:%S %p1/30/2017 11:14:55 AM+%s), name (null) input record number 1, file mycsv.csv source line number 1  I know that the date conversion for the field works so I am doing something wrong with the syntax.How can I do what I want?
Convert column using date and append to csv file
text processing;awk;osx;date;csv
I have GNU date and hence the command line options are different for me. But you problem seems to be awk's syntax: You can not use the shell subprocess construct $(...) inside awk scripts. You need to you the system() function, which gets passed a string. Therefore you need to construct a valid shell command into an awk string that you can pass to system inside the awk script.Something like this:awk -F , 'BEGIN{ OFS=, } {$14=system(date -jf \%m/%d/%Y %H:%M:%S %p\ \$1\ \+%s\); print}' mycsv.csv > testor for better readablilityawk -F , '  BEGIN{ OFS=, }  {    $14 = system(date -jf \%m/%d/%Y %H:%M:%S %p\ \ $1 \ \+%s\);    print  }' \  mycsv.csv > test