What date

chinou toure Posted messages 18 Status Member -  
 jj -
Hello,
I would like a script that calculates the day of the month for a given date in UNIX command line (shell)
Configuration: Linux Firefox 3.0

2 answers

  1. jj
     
    Hello,

    a little script like this:

    # we retrieve the date as parameters of the script
    day=$1
    month=$2
    year=$3
    one=0
    max_month=$[month-1]
    # we retrieve the duration of the months before the date
    for mc in $(seq 1 1 $max_month)
    do

    u=$(cal $mc $year | awk ' NF!=0 {toto=$(NF) } END{print toto}')
    one=$[one+u]
    done

    unitary=$[one+day]
    echo $unitary

    a check is missing to avoid executing the loop if we are in January.
    0