confuseddddd
Programmer
Have the following nawk script and appears the file is being truncated...
The script reads the current date, reads the input file for every occurance of BBIL and then writes out all records between each BBIL to a specific person's file; however, appears some of the records are being truncated. There is no length given, so why would the truncation occur??? Is there an assumption within a nawk script that the record length is 512, if so, how can we increase that???
nawk 'BEGIN{
FS=" "
PRE='`date -u +%Y%m%d`'
XXXCNT=0
TOTBILL=0
}
##Now the main loop begins, looking for all BBIL (start of bill) records
##If BBIL, then 2nd field, position 17, for a length of 3, will be the user id
{
if ( substr($1,1,4) == "BBIL" ) {
VAR=substr($2, 17, 3)
TOTBILL+=1
##Test if VAR is a valid user
##If not valid user, then set user to XXX and increment XXX count
if ( VAR != "VML" && VAR != "CAT" && VAR != "REG" && VAR != "HYD" && VAR != "DDS" && VAR != "PJM" && VAR != "BQT" && VAR != "JXB" && VAR != "GGL" && VAR != "NAJ" &&
VAR != "SQF" && VAR != "TTY" && VAR != "PKP" && VAR != "MAW" )
{
VAR="XXX"
XXXCNT+=1
}
#
}
#
## Substitute the trailing spaces with null values
## Send input records to user output files
sub(/ *.$/,"")
print $0 >> PRE"_I01."VAR
}
The script reads the current date, reads the input file for every occurance of BBIL and then writes out all records between each BBIL to a specific person's file; however, appears some of the records are being truncated. There is no length given, so why would the truncation occur??? Is there an assumption within a nawk script that the record length is 512, if so, how can we increase that???
nawk 'BEGIN{
FS=" "
PRE='`date -u +%Y%m%d`'
XXXCNT=0
TOTBILL=0
}
##Now the main loop begins, looking for all BBIL (start of bill) records
##If BBIL, then 2nd field, position 17, for a length of 3, will be the user id
{
if ( substr($1,1,4) == "BBIL" ) {
VAR=substr($2, 17, 3)
TOTBILL+=1
##Test if VAR is a valid user
##If not valid user, then set user to XXX and increment XXX count
if ( VAR != "VML" && VAR != "CAT" && VAR != "REG" && VAR != "HYD" && VAR != "DDS" && VAR != "PJM" && VAR != "BQT" && VAR != "JXB" && VAR != "GGL" && VAR != "NAJ" &&
VAR != "SQF" && VAR != "TTY" && VAR != "PKP" && VAR != "MAW" )
{
VAR="XXX"
XXXCNT+=1
}
#
}
#
## Substitute the trailing spaces with null values
## Send input records to user output files
sub(/ *.$/,"")
print $0 >> PRE"_I01."VAR
}