I'm trying to parse a log file that starts with a formatted date column:
06/22/2015 00:17:59
I'm using the following code to convert it into a unix timestamp:
unix="date -d\""$1" "$2"\" \"+%s\""; unix | getline timestamp;
However, when I do this, awk fails with following error:
awk: (FILENAME=/dev/fd/63 FNR=263350) fatal: cannot open pipe 'date -d"06/22/2015 00:17:59" "+%s"' (Too many open files)
Any way to deal with this, or to parse the date differently?
Your problem is that you need to close your command:
unix="date -d\""$1" "$2"\" \"+%s\""; unix | getline timestamp; close(unix)
If you don't do this, a new pipe is opened for each record in your input file, which leads to the problem that you are experiencing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With