I am a newbie in bash programming. I need a bash script which can check if there is an input or not.If there is an input then continue to the second question, otherwise it will not continue unless it forces me to write the input (data). I wrote this script but is not working:
echo "Write buss no:"
read bussno
while [ true ] ; do
if [ -z $bussno ] ; then
echo "\Buss No. should be filled"
read bussno
else
echo "Write from date: "
read startdate
if [ -z $startdate ] ; then
echo "\start date should be filled"
read startdate
fi
done
There are ways, but you want to keep it simple, yes?
Maybe the logic you want is something like
This still leaves a lot to be desired in terms of data confirmation, though.
You can add a regex for that if you want, and some follow up confirmations.
For example, for the date,
These still leave much to be desired, but it's a start.