Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 84

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
FreeBSD on EC2 FreeBSD ( is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.:
Suggested Courses

704 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