Last active
February 22, 2022 18:36
-
-
Save mluis7/471a8a365f667d28135400e690816ad7 to your computer and use it in GitHub Desktop.
Palindrome dates since year 1001 - dd-mm-yyyy format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
y="1001" | |
for i in $(seq 1001 2153); do | |
y="$i" | |
m=$(echo "${y:0:2}" | rev) | |
d=$(echo "${y:2:2}" | rev) | |
rv=$(echo "$d$m" | rev) | |
if [ "$d" -le 31 ] && [ "$m" -le 12 ] && [ "$rv" == "$y" ]; then | |
if date -d "${y}-${m}-${d}" > /dev/null 2>&1; then | |
echo "$d-$m-$y" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result:
