Sponsored Content
Top Forums Shell Programming and Scripting [: 2016-02-29: integer expression expected Post 302972939 by pravin27 on Thursday 12th of May 2016 03:52:48 AM
Old 05-12-2016
Convert your date to seconds and then compare.
Code:
dProcDate="2016-02-29"
dCurrent="2016-05-31"

dProcDate_sec=$(date -d"$dProcDate" '+%s')
dCurrent_sec=$(date -d"$dCurrent" '+%s')

if [ $dProcDate_sec -le $dCurrent_sec ]; then
echo $dProcDate
else
echo $dProcDate2
fi

This User Gave Thanks to pravin27 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Integer Expression Expected

Cannot figure out what the error is on line #10 I was trying to change my login prompt though I've success with that this shows up as well. Here's what I have (1 Reply)
Discussion started by: moonunit
1 Replies

2. Shell Programming and Scripting

:integer expression expected

Hi, echo $i until || do read NUM if && ; then printf "$FBOLD\nInvalid number, please enter valid backup number: $FREG" fi done Getting below error : ./import_location.sh: line 234: [: : integer expression expected ./import_location.sh: line 234: [: :... (5 Replies)
Discussion started by: milink
5 Replies

3. Shell Programming and Scripting

Integer expression expected: with regular expression

CA_RELEASE has a value of 6. I need to check if that this is a numeric value. if not error. source $CA_VERSION_DATA if * ] then echo "CA_RELESE $CA_RELEASE is invalid" exit -1 fi + source /etc/ncgl/ca_version_data ++ CA_PRODUCT_ID=samxts ++ CA_RELEASE=6 ++ CA_WEEK_NO=7 ++... (3 Replies)
Discussion started by: ketkee1985
3 Replies

4. UNIX for Dummies Questions & Answers

Integer Expression Expected!?!?

Ok, so I am beggining a script to factor the time difference from when a user logs on to current time but before I can even get too far I am getting the INTEGER EXPRESSION EXPECTED error. Can someone tell me what I am doing wrong? lhour=$(who | grep "$1" | cut -c30,31); lmin=$(who | grep "$1"... (1 Reply)
Discussion started by: losingit
1 Replies

5. Shell Programming and Scripting

Integer expression expected

Newb here echo "$yesterdaysclose" echo "$close" if ; then echo "stocks moving up" elif ; then echo "stock is moving down" else echo "no change" fi seems to evaluate the floating decimal correctly however returns ./shellscript1.sh: line 17: [: : integer expression expected... (3 Replies)
Discussion started by: harte
3 Replies

6. Shell Programming and Scripting

Integer expression expected

hi Guys, when i run the below script its showing error "integer expression expected" script pasted below: #!/bin/sh for i in {1..$2} do if then scp server1:/root/file.2012-$1-0$i . else scp server1:/root/file.2012-$1-$i . fi done (8 Replies)
Discussion started by: ganga39
8 Replies

7. Shell Programming and Scripting

Integer expression expected

Hi, I have placed the script and running successfully on AIX However in Linux it throws integer expression expected Could some one please help me to fix this MaxThreshold4alert=`echo "$MaxCapacitycnt*(80/100)" |bc -l` echo $MaxThreshold4alert Error: 40.00000000000000000000: integer... (2 Replies)
Discussion started by: ajothi
2 Replies

8. Shell Programming and Scripting

Integer expression expected

I need some help with this if but then it says line 11: I don't know what I'm doing wrong (1 Reply)
Discussion started by: margg
1 Replies

9. Shell Programming and Scripting

Integer expression expected

Hi, I am getting the below error while comparing the month of a file to current month. I am using ls -lrth to get the month of that file and while using the if else condition i am getting the below error.. a1=`ls -lrth abc.txt | awk '{print substr($6,1,3)}'` This gives me the month from... (1 Reply)
Discussion started by: jaituteja
1 Replies

10. Shell Programming and Scripting

Integer expression expected

Hello , This is the piece of the code which is giving me trouble if ;then exit_proc "${SOURCEDIR}/${OUT_FILE} does not exists or not readable" 2 else word_count=`wc -l < ${SOURCEDIR}/$OUT_FILE` fi if ;then exit_proc "Word_count is more than allowed limit" 1 else... (6 Replies)
Discussion started by: Sri3001
6 Replies
Tcl_ExprLongObj(3)					      Tcl Library Procedures						Tcl_ExprLongObj(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tcl_ExprLongObj, Tcl_ExprDoubleObj, Tcl_ExprBooleanObj, Tcl_ExprObj - evaluate an expression SYNOPSIS
#include <tcl.h> int Tcl_ExprLongObj(interp, objPtr, longPtr) int Tcl_ExprDoubleObj(interp, objPtr, doublePtr) int Tcl_ExprBooleanObj(interp, objPtr, booleanPtr) int Tcl_ExprObj(interp, objPtr, resultPtrPtr) ARGUMENTS
Tcl_Interp *interp (in) Interpreter in whose context to evaluate objPtr. Tcl_Obj *objPtr (in) Pointer to an object containing the expression to evaluate. long *longPtr (out) Pointer to location in which to store the integer value of the expression. int *doublePtr (out) Pointer to location in which to store the floating-point value of the expression. int *booleanPtr (out) Pointer to location in which to store the 0/1 boolean value of the expression. Tcl_Obj **resultPtrPtr (out) Pointer to location in which to store a pointer to the object that is the result of the expression. _________________________________________________________________ DESCRIPTION
These four procedures all evaluate an expression, returning the result in one of four different forms. The expression is given by the objPtr argument, and it can have any of the forms accepted by the expr command. The interp argument refers to an interpreter used to evaluate the expression (e.g. for variables and nested Tcl commands) and to return error information. For all of these procedures the return value is a standard Tcl result: TCL_OK means the expression was successfully evaluated, and TCL_ERROR means that an error occurred while evaluating the expression. If TCL_ERROR is returned, then a message describing the error can be retrieved using Tcl_GetObjResult. If an error occurs while executing a Tcl command embedded in the expression then that error will be returned. If the expression is successfully evaluated, then its value is returned in one of four forms, depending on which procedure is invoked. Tcl_ExprLongObj stores an integer value at *longPtr. If the expression's actual value is a floating-point number, then it is truncated to an integer. If the expression's actual value is a non-numeric string then an error is returned. Tcl_ExprDoubleObj stores a floating-point value at *doublePtr. If the expression's actual value is an integer, it is converted to float- ing-point. If the expression's actual value is a non-numeric string then an error is returned. Tcl_ExprBooleanObj stores a 0/1 integer value at *booleanPtr. If the expression's actual value is an integer or floating-point number, then they store 0 at *booleanPtr if the value was zero and 1 otherwise. If the expression's actual value is a non-numeric string then it must be one of the values accepted by Tcl_GetBoolean such as "yes" or "no", or else an error occurs. If Tcl_ExprObj successfully evaluates the expression, it stores a pointer to the Tcl object containing the expression's value at *resultP- trPtr. In this case, the caller is responsible for calling Tcl_DecrRefCount to decrement the object's reference count when it is finished with the object. SEE ALSO
Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBoolean, Tcl_ExprString, Tcl_GetObjResult KEYWORDS
boolean, double, evaluate, expression, integer, object, string Tcl 8.0 Tcl_ExprLongObj(3)
All times are GMT -4. The time now is 06:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy