Dear Community;
I have a csv file with msb and lsb in $3 and $5 fields which provides the epochtime (factor 65536). Further I need to convert epochtime to readable datetime.
But am getting an error.
File Sample:
5000a,1000,20671,0,16421,0,1,NULL,0
5000b,1000,20974,0,-16284,0,1,NULL,0
5000c,1000,20974,0,-16269,0,1,NULL,0
5000d,1000,20974,0,-16237,0,1,NULL,0
5000e,1000,20974,0,-16215,0,1,NULL,0
5000f,1000,20974,0,-16194,0,1,NULL,0
5000g,1000,20671,0,16421,0,1,NULL,0
Command:
awk -F, 'BEGIN {OFS = FS} {epochtime=($3*65536+$5)} {"date -r "epochtime"" | getline starttime} {$3=starttime; print}' offer_disabled.txt
Error:
awk: date -r 1374535870 makes too many open files
input record number 33, file offer_disabled.txt
source line number 1
Other Attempts (ref: similar issues)
awk -F, 'BEGIN {OFS = FS} {epochtime=($3*65536+$5)} {"date -r "epochtime"" | getline starttime; close(epochtime)} {$3=starttime; print}' offer_disabled.txt
Or
awk -F, 'BEGIN {OFS = FS} {epochtime=($3*65536+$5)} {"date -r "epochtime"" | getline starttime; close(starttime)} {$3=starttime; print}' offer_disabled.txt
Or
awk -F, 'BEGIN {OFS = FS} {epochtime=($3*65536+$5)} {"date -r "epochtime"" | getline starttime; close(epochtime); close(starttime)} {$3=starttime; print}' offer_disabled.txt
Or
awk -F, 'BEGIN {OFS = FS} {"date -r "$3*65536+$5"" | getline starttime; close(starttime)} {$3=starttime; print}' offer_disabled.txt
But the same error is returned.
If I run line 33 output
date -r 1374535870
on CLI, it works fine.
Please guide on this issue.
########################
Just to add, am running this on OS X
########################
BR//