Change type

Posted on 1999-09-07
Medium Priority
Last Modified: 2010-04-21
I have used the "date" command for the following in Bourne Shell :
var1=`date +%d` to print the date, the result like 08 which is the date no.  However, it is a string.  I want to substract the var1 by 1.  So, the result will be 07.  How can i do that?
Question by:HenryChang
LVL 85

Expert Comment

ID: 2027148
expr \( 1$var - 1 \) : '1\(.*\)'

Accepted Solution

kotamraju earned 200 total points
ID: 2028129
export var1=`date +%d` | expr $var1 - 1

Author Comment

ID: 2029023
the syntax is not work.  I have tried another expressions :

var1=`date +%d`
var1=`expr $var1 - 1`

It work for this expression

Expert Comment

ID: 6821592
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects that and the expert will now receive these points, all verified.

Please click on your Member Profile, select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.
Moderator @ Experts Exchange

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question