megashares
asked on
How to prevent some case when input datetime ?
This code below is check leap year and invalid day completed.
But I have some problem.I try to make an trap.People insert blank space when enter day, and program not accept and sad input invalid day again ( not blank space). I try any time it not worked :|. I new to shell scripting. Please help
But I have some problem.I try to make an trap.People insert blank space when enter day, and program not accept and sad input invalid day again ( not blank space). I try any time it not worked :|. I new to shell scripting. Please help
#!/bin/bash
result="FALSE"
while [ $result = "FALSE" ]
do
echo -n "Enter day(mm/dd/yyyy): "
read datetime
if date --date="$datetime" >/dev/null
then
result="TRUE"
else
result="FALSE"
fi
done
ASKER
Enter day(mm/dd/yyyy): I press "enter button" or spacebar and enter. I out my program. I want when someone press some thing like this my program will not accept and notice to enter an valid value again
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
don't see a reason for a delete, valid suggestions are there
could you please explain?
could you please explain?
Can you please show us an example.