/dev/null 2>&1 } # Check if the user provided an argument if [ $# -ne 1 ]; then echo "Usage: $0 YYYY-MM-DD" exit 1 fi # Get the input date input_date="$1" # Check if the date is valid if is_valid_date "$input_date"; then echo "The date $input_date is valid." else echo "The date $input_date is not valid." fi"> /dev/null 2>&1 } # Check if the user provided an argument if [ $# -ne 1 ]; then echo "Usage: $0 YYYY-MM-DD" exit 1 fi # Get the input date input_date="$1" # Check if the date is valid if is_valid_date "$input_date"; then echo "The date $input_date is valid." else echo "The date $input_date is not valid." fi"> /dev/null 2>&1 } # Check if the user provided an argument if [ $# -ne 1 ]; then echo "Usage: $0 YYYY-MM-DD" exit 1 fi # Get the input date input_date="$1" # Check if the date is valid if is_valid_date "$input_date"; then echo "The date $input_date is valid." else echo "The date $input_date is not valid." fi">
#!/bin/bash
# Function to check if the date is valid
is_valid_date() {
date -d "$1" "+%Y-%m-%d" >/dev/null 2>&1
}
# Check if the user provided an argument
if [ $# -ne 1 ]; then
echo "Usage: $0 YYYY-MM-DD"
exit 1
fi
# Get the input date
input_date="$1"
# Check if the date is valid
if is_valid_date "$input_date"; then
echo "The date $input_date is valid."
else
echo "The date $input_date is not valid."
fi