1

I'm trying to subtract the first day of class (17Feb13 day#47) from the current day (24Feb13 day#55) The command date +%j yields 055, instead of 55 so the math errors...

todayIn=$(date +%j)................= 055

firstDay=(47)..........................= 47

myVal=$(todayIn-firstDay)....= error (expecting 8)

2 Answers 2

1

It seems like it should be enough to just strip the leading zero(es) with:

todayIn=$(date '+%j' | sed -e 's/^0*//')
Sign up to request clarification or add additional context in comments.

1 Comment

Millimoose, Thank you, that was what I needed!
0

Or use expr:

$ a=$(expr 055 - 5)
$ echo $a
$ 50

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.