Hi,
I am looking for the following:
- A command to 'grep' the variable from a file
- And check whether the entered variable is empty in that file
I have a file as given below:
IAGLOBAL_USERID=admin
I want to check with a whether the variable contains a value, say here its admin if it contains value I will proceed ahead else I should give three tries for the user if in those three tries if the user does not enter the userid then I will exit.
I did the following:
var1=`cat $NCO/response_uid.txt | grep -i IAGLOBAL_WASUserID | cut -d'=' -f1`
var2=$(echo "${var1}" | sed -e 's/^ *//g;s/ *$//g')
echo $var2
if [ -z "$var2" ];
then
rm -rf $NCO/response_uid.txt
rm -rf $NCO/response_def.txt
exit 1;
fi
Any ideas?
Thanks,
Dinesh