I have written a script where each record in the input file is delimited into fields by "|". I use cut to put each field into a variable. How do I test all 4 variables for a single value? I want to make sure that all 4 variables are present in the input record (i.e., not = null). Now, I have 4 separate if stmts. There's got to be a better way!
Thanks for any help!
Input record sample:
db|mart|table|column
db|mart|table
db
These last 2 records should be detected as incomplete.
Part of the script:
while read STATINFO
do
ERROR=N
echo ${STATINFO} > stats_wrapper.wrk
DATABASE=`grep "|" stats_wrapper.wrk | cut -d"|" -f1`
MART=`grep "|" stats_wrapper.wrk | cut -d"|" -f2`
TABLE=`grep "|" stats_wrapper.wrk | cut -d"|" -f3`
COLUMN=`grep "|" stats_wrapper.wrk | cut -d"|" -f4`
if [[ ${DATABASE} = "" ]]
then
ERROR=Y
fi
if [[ ${MART} = "" ]]
then
ERROR=Y
fi
if [[ ${TABLE} = "" ]]
then
ERROR=Y
fi
if [[ ${COLUMN} = "" ]]
then
ERROR=Y
fi
if [[ ${ERROR} = @(Y) ]]
echo "INPUT value missing"
else
echo "INPUT OK"
fi
done < ${STATLIST}
Thanks for any help!
Input record sample:
db|mart|table|column
db|mart|table
db
These last 2 records should be detected as incomplete.
Part of the script:
while read STATINFO
do
ERROR=N
echo ${STATINFO} > stats_wrapper.wrk
DATABASE=`grep "|" stats_wrapper.wrk | cut -d"|" -f1`
MART=`grep "|" stats_wrapper.wrk | cut -d"|" -f2`
TABLE=`grep "|" stats_wrapper.wrk | cut -d"|" -f3`
COLUMN=`grep "|" stats_wrapper.wrk | cut -d"|" -f4`
if [[ ${DATABASE} = "" ]]
then
ERROR=Y
fi
if [[ ${MART} = "" ]]
then
ERROR=Y
fi
if [[ ${TABLE} = "" ]]
then
ERROR=Y
fi
if [[ ${COLUMN} = "" ]]
then
ERROR=Y
fi
if [[ ${ERROR} = @(Y) ]]
echo "INPUT value missing"
else
echo "INPUT OK"
fi
done < ${STATLIST}