how to compare the runtime input with text file
I want to compare the input and text file word.
The text file has:
one
two
three
Run time input assigned to a variable var:
read -p " enter the value : " var
while read first
do
a=$first
if [ "$a" == "$var" ]
then
echo " $var is found "
else
echo " $var is not found "
read -p " please enter correct value " $var
fi
done < word.txt
I tried above code in my script, but it is not working.
The text file has:
one
two
three
Run time input assigned to a variable var:
read -p " enter the value : " var
while read first
do
a=$first
if [ "$a" == "$var" ]
then
echo " $var is found "
else
echo " $var is not found "
read -p " please enter correct value " $var
fi
done < word.txt
I tried above code in my script, but it is not working.
Комментарии
Отправить комментарий