Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if [ "`date '+%Y-%m-%d' -d $d 2>/dev/null`" == "$d" ]
- then
- echo "1"
- elif [ "`date '+%d-%m-%Y' -d $d 2>/dev/null`" == "$d" ]
- then
- echo "2"
- elif [ "`date '+%Y/%m/%d' -d $d 2>/dev/null`" == "$d" ]
- then
- echo "3"
- elif [ "`date '+%d/%m/%Y' -d $d 2>/dev/null`" == "$d" ]
- then
- echo "4"
- else
- echo `date '+%d-%m-%Y' -d $d`
- echo "other"
- fi
- date: invalid date `01-01-2018'
- other
- case $d in
- [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9])
- # assume yyyy-mm-dd
- ;;
- [0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9])
- # in the civilized world, assume dd/mm/yyyy
- # in the US, assume mm/dd/yyyy
- # in the general case, assume nothing; give up
- ;;
- ... etc ...
- esac
Add Comment
Please, Sign In to add comment