If you get 'too many open files', try this:
find /dupgprs/data/ -type f |
grep -v "\.out" | # Ignore previously parsed files
xargs awk 'BEGIN { getline FNUM < "/tmp/FNUM"; close("/tmp/FNUM"); }
END { printf("%d\n", FNUM) > "/tmp/FNUM"; }
FNR==1{ FNUM++; if(LF) close(LF); LF=FILENAME ".out" }
{ printf("%s|0| | | | | | | |%08d%08d |\n", FNUM, FNR) > LF; }'
awk: cmd. line:3: (FILENAME=/dupgprs/data/gsmconsolidated201404052345340 FNR=1) fatal: not enough arguments to satisfy format string
`%s |0| | | | | | | |%08d%08d |
'
^ ran out for this one
find /dupgprs/data/ -type f |
grep -v "\.out" | # Ignore previously parsed files
xargs awk 'BEGIN { getline FNUM < "/tmp/FNUM"; close("/tmp/FNUM"); }
END { printf("%d\n", FNUM) > "/tmp/FNUM"; }
FNR==1{ FNUM++; if(LF) close(LF); LF=FILENAME ".out" }
{ printf("%s|0| | | | | | | |%08d%08d |\n", $0, FNUM, FNR) > LF; }'
you are the man. Tried the script on a batch of 427 cdr's and it uploaded like charm. Thanks a lot man. You have no idea, how much you have helped me.
1 Like