Calculate day number from date function fg: no job control

I have a function to calculate day number based on three parameters d,m,y

this is the function

function getDate (){
    d=$1
    m=$2
    y=$3
    m=$((m+9)) % 12
    y=$((y - m/10))
    return $((365*y + y/4 - y/100 + y/400 + (m*306 + 5)/10 + ( d - 1 )))
}

Call for example :

getDate 01 01 2015

The problem is I get always line 8: fg: no job control which is this line m=$((m+9)) % 12


Source: unix

Leave a Reply