11-28-2001
time arithmetic
Can anyone help please. I am writing a kourne shell script and I am unsure how to do the following:
I have extracted a time string from a logfile, and I have another time string I want to compare it to to see if it's later than the time I'm comparing with.
i.e. expectedSLA="23:00:00", actualDeliveryTime="22:40:00"
I try to do the following:
missedSLA="N"
if [ $actualDeliveryTime > $expectedSLA ]
then
missedSLA="Y"
fi
This always sets missedSLA to "Y". Isn't it supposed to compare using the decimal values of the string? How can I get the above process to work? What can I do? Any help would be greatly appreciated.
Many thanks,
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
i am used to making scripts for hp-ux. but lately i tried to make some for solaris. the problem is that when i tried to execute it it gave me an error the "let: not found". why is that? how can i perform an arithmetic function in the solaris shell script?
thanks :) (2 Replies)
Discussion started by: inquirer
2 Replies
2. UNIX for Dummies Questions & Answers
I am a beginner and I have been searching the web all morning for this answer but can't find it anywhere.
I know that
prtint 1*2
will return
1*2
what if i actually want the problem to be calculated
so i want
print 1*2
to return
2
How is this done? (3 Replies)
Discussion started by: tygun
3 Replies
3. Shell Programming and Scripting
Helloo..
I am trying one very simple thing I could not find anything on google..
I have 2 integer variable..and I need to do division...in ksh
where $catch and $num are integer variable..
I tryed with this:
printf "%0.2f" $final=$catch/$num
but it does not work..
any help is... (12 Replies)
Discussion started by: amon
12 Replies
4. Shell Programming and Scripting
Yes I know tcsh sucks for scripting and arithmetic but I have to write a script for multiple users and they all use tcsh.
I have this variable that I 'set' with but pulling numbers off of stings with
set STUFF = `grep string file | awk command`
Now I would like to add up the numbers that... (4 Replies)
Discussion started by: gobi
4 Replies
5. UNIX for Dummies Questions & Answers
Hello,
I have a list of 'inputs' and i want to convert those on the second list named 'Desired Outputs', but i don't know how to do it?
Inputs Desired Outputs
1 2
94 4
276 8
369 10
464 12 ... (0 Replies)
Discussion started by: filda
0 Replies
6. UNIX for Dummies Questions & Answers
Hello all,
I'd like to know how to perform arithmetic on multiple files. I have got many tab-delimited files. Each file contains about 2000 rows and 2000 columns.
What I want to do is to to sum the values in each row & column in every file.
The following explains what I want to do;
... (9 Replies)
Discussion started by: Muhammad Rahiz
9 Replies
7. Shell Programming and Scripting
Hello,
Could someone explain how this one is possible:
# @ x = 10 - 11 + 3
# echo $x
-4
I know that writing script using csh is bad idea, but I need to write few lines.
thanks
Vilius (2 Replies)
Discussion started by: vilius
2 Replies
8. Shell Programming and Scripting
Hi,
I need to process a file which contains below data. Usually the files contains both Start and Finish time. but for Few records, it contains only Start. For those records I need to add the finish line by adding 5 minutes to Start time.
Started BBIDX Tue Jun 1 15:15:11 EDT 2010 292308... (1 Reply)
Discussion started by: siba.s.nayak
1 Replies
9. Shell Programming and Scripting
Hello fellow forum members,
I wrote below piece of code to calculate the date after a given date -
date=$DATE_FINAL
declare -a max_month=(0 31 28 31 30 31 30 31 31 30 31 30 31)
eval $(echo $date|sed 's!\(....\)\(..\)\(..\)!year=\1;month=\2;day=\3!')
(( year4=year%4 ))
(( year100=year%100... (9 Replies)
Discussion started by: ektubbe
9 Replies
10. Shell Programming and Scripting
I need to divide the number of white spaces by total number of characters in a file using bash. I am able to get the number of white spaces correctly using:
tr -cd < afile | wc -c
I am also able to get the total number of characters using:
wc -c afile
How do I divide the first... (2 Replies)
Discussion started by: ngabrani
2 Replies