Skip to content

Instantly share code, notes, and snippets.

@mluis7
Last active February 22, 2022 18:36
Show Gist options
  • Save mluis7/471a8a365f667d28135400e690816ad7 to your computer and use it in GitHub Desktop.
Save mluis7/471a8a365f667d28135400e690816ad7 to your computer and use it in GitHub Desktop.
Palindrome dates since year 1001 - dd-mm-yyyy format
#!/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
@mluis7
Copy link
Author

mluis7 commented Feb 22, 2022

Result:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment