I know how to check the status of the previously executed command using $?, and we can make that status using exit command. But for the loops in bash are always returning a
I would like to submit an alternative solution which is simpler and I think more elegant:
(while true
do
if [ -f "test" ] ; then
break
fi
done
Of course of this is part of a script then you could user return 1 instead of exit 1
exit 1
)
echo "Exit status is: $?"