BASH
#!/bin/bash
from=$1
if [ "$from" = "" ]; then
from=`date +%Y-%m-%d`
fi
i=1
while [ "$isFri" = "" ] || [ "$is13" = "" ]
do
isFri=`date -d "${from} ${i} days" | grep Fri`
is13=`date -d "${from} ${i} days" +%Y-%m-%d | grep "\-13"`
((i++))
done
((i--))
date -d "${from} ${i} days" +%Y-%m-%d
CONCEPT USED:
$ date -d "2011-02-16 2 days" +%Y-%m-%d
2011-02-18
SAMPLE I/O
:~/aman> ./fr13th.sh
2011-05-13
:~/aman> ./fr13th.sh 2013-05-09
2013-09-13
:~/aman> ./fr13th.sh 2007-06-29
2007-07-13
:~/aman> ./fr13th.sh 2007-07-13
2008-06-13