I am learning shell bash now, and tried to figure it out how to compare expr result on IF condition.
Basically want to return only odd natural numbers
The code
a=1
while [ $a -lt 10 ]
do
echo "test " $a % 2 " = " `expr $a % 2`
if [`expr $a % 2`]
then
echo $a
fi
a=`expr $a + 1`
done
I wish the result should be
1
3
5
7
9
New contributor
deSharp is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.