Results 1 to 2 of 2

Thread: days of month in variable not working

  1. #1
    Join Date
    Aug 2013
    Beans
    37

    days of month in variable not working

    Hi guys i want to get the number of days in next month in a variable so i can loop through it so far i have

    cal $(date +"%m %Y" --date "next month") | awk 'NF {DAYS = $NF}; END {print DAYS}' > temp
    DAYS_IN_NEXT_MONTH=$(cat temp)



    for (( c=1; c<=$DAYS_IN_NEXT_DATE; c++ ))
    do

    echo $c

    done
    but it s giving the error


    ((: c<=: syntax error: operand expected (error token is "<=")
    Ive used variable in a for next loop before so don't understand why this isn't working ? any give me a heads up[ and id be grateful

    Cheers Pete

  2. #2
    Join Date
    Aug 2010
    Location
    Lancs, United Kingdom
    Beans
    1,588
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: days of month in variable not working

    If what you've pasted is exactly what you are doing, then the problem is that DAYS_IN_NEXT_MONTH is not the same as DAYS_IN_NEXT_DATE.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •