How can I add days to the logic in my shell script?
I am on AIX c shell and trying to add days.
I have
#!/bin/sh
Today=`date +%u` # which gives me 5
Tomorrow='expr ${Today} + 1' # do nothing
could you please let me know how to increase day of the week by 1?
Solution 1:
Your problem is you put your expr
statement in single quotes, which prevents the shell from replacing ${Today}
with 5
, and prevents it from executing the expr
instruction (it just stores the whole expression as a string in the Tomorrow
variable).
You probably want something like this:
#!/bin/sh
Today=`date +%u` # which gives me 5
Tomorrow=`expr ${Today} + 1` # works
echo $Tomorrow # outputs 6