December 1999
Beginner
528 pages
11h 10m
English
The tasks involved in adding a record to a file are the following:
1. |
Validate the input.
|
2. |
Write the record(s) to a file.
|
The first task we need to do is put some functions together that can tell us whether the fields are numeric or character based and the length of the fields. This will be our data input validation, which will be used with records that are added as well as amended. Luckily we already have some of these functions at hand.
Function to check the length of a string:
length_check()
{
# length_string
# $1=string, $2= length of string not to exceed this number
_STR=$1
_MAX=$2
_LENGTH=`echo $_STR |awk '{print length($0)}'`
if [ "$_LENGTH" -gt "$_MAX" ]; then
return 1
else
return 0
fi
}Function to check ...
Read now
Unlock full access