initial commit
This commit is contained in:
42
chapter5/function_parse_variable_length_records
Executable file
42
chapter5/function_parse_variable_length_records
Executable file
@@ -0,0 +1,42 @@
|
||||
function parse_variable_length_records
|
||||
{
|
||||
# set -x
|
||||
# Zero out the $OUTFILE
|
||||
|
||||
>$OUTFILE
|
||||
|
||||
# Associate standard output with file descriptor 4
|
||||
# and redirect standard output to $OUTFILE
|
||||
|
||||
exec 4<&1
|
||||
exec 1> $OUTFILE
|
||||
|
||||
while read RECORD
|
||||
do
|
||||
# On each loop iteration extract the data fields
|
||||
# from the record as we process the record file
|
||||
# line by line
|
||||
|
||||
echo $RECORD | awk -F : '{print $1, $2, $3, $4, $5, $6}' \
|
||||
| while read BRANCH ACCOUNT NAME TOTAL DATEDUE RECFILE
|
||||
do
|
||||
# Perform some action on the data
|
||||
|
||||
process_variablelength_data_new_duedate $BRANCH $ACCOUNT $NAME \
|
||||
$TOTAL $DATEDUE $RECFILE $NEW_DATEDUE
|
||||
if (( $? != 0 ))
|
||||
then
|
||||
# Note that $LOGFILE is a global variable
|
||||
echo "Record Error: $RECORD" | tee -a $LOGFILE
|
||||
fi
|
||||
done
|
||||
|
||||
done < $MERGERECORDFILE
|
||||
|
||||
# Restore standard output and close file
|
||||
# descriptor 4
|
||||
|
||||
exec 1<&4
|
||||
exec 4>&-
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user