f=0
echo "Enter roll no"
read rn
test1=` echo $rn | grep -x -E '[[:digit:]]+' `
len=` echo -n $test1 | wc -m `
if [ $len -eq 0 ]
then
echo "Roll number accept only number"
f=1
fi
echo "Enter name"
read name
test2=` echo $name | grep -x -E '[^0-9]+' `
len2=` echo -n $test2 | wc -m `
if [ $len2 -eq 0 ]
then
echo "Name accept only character"
f=1
fi
echo "Enter marks"
read marks
if [ $marks -lt 0 -o $marks -gt 100 ]
then
echo "Marks must be between 0 to 100"
f=1
fi
if [ $f -eq 0 ]
then
echo "Your all input is accepted"
echo "$rn $name $marks" >> stud.txt
echo "Content of your file is "
cat stud.txt
else
echo "Sorry your input is not accpted"
fi
Leave a Reply