Advertisement
metalx1000

BASH validate date format

May 15th, 2021
2,043
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.23 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. read -p "What is the date of the event? " d
  4.  
  5. date -d "$d" -I > /dev/null|| exit 1
  6. date="$(date -d "$d" +%m/%d/%Y)"
  7. day="$(date -d "$d" +%A)"
  8.  
  9. echo "You Selected $date"
  10. echo "and $day was the day of the week"
  11.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement