Compare two time (HH:MM:SS) - ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Compare two time (HH:MM:SS) - ksh
# 1  
Old 10-16-2015
Compare two time (HH:MM:SS) - ksh

Is it possible to compate two time (24-hour format)?

What I need is to just check if the first time is earlier than the second time.

ex:

./script.ksh 09:30:15 13:00:34 = okay

./script.ksh 05:25:00 02:30:50 = invalid arguments
# 2  
Old 10-16-2015
Convert the time stamp into number of seconds from epoch and then its a simple numerical comparison. Doing so is left as an exercise to the OP :-)
This User Gave Thanks to balajesuri For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh scripting SSH to Compare File Sizes

Hello, I currently have very little experience with Shell scripting and trying to create a script for the purpose of collecting the size of a couple sizes on 4 different Hosts. The Idea is to collected the information from the files in which the script is kicked off on, store the values into... (17 Replies)
Discussion started by: Abstract3000
17 Replies

2. Shell Programming and Scripting

Ksh: how compare content of a file with an other array

Hi, I created a skript in ksh which generate a file with semicolon as separator, this is an example of the file a created: example content file: hello;AAAA;2014-08-17 hello;BBBB;2014-08-17 hello;CCCC;2014-08-17 I would need to compare the content in of the second column of this file... (3 Replies)
Discussion started by: jmartin
3 Replies

3. Shell Programming and Scripting

How to compare day in ksh on AIX?

we made a script in which i am putting a day in a variable by this command d8 = `date +%a` after that I am checking for next working day meand week days only for eg. if today is Monday than previous day would be Friday and if today is Friday than next day is Monday else it would be date +1... (1 Reply)
Discussion started by: pallvi_mahajan
1 Replies

4. Shell Programming and Scripting

ksh to compare alphanumeric values from 2 files

Hi there, I want to compare 2nd column which are alphanumeric values from each of the 2 files i.e.,lspv_pre.out and lspv_post.out , if found echo some message. lspv_pre.out hdisk0 00c39eaa451144dd rootvg active hdisk1 00c39eaa45223322 ... (3 Replies)
Discussion started by: mbak
3 Replies

5. Shell Programming and Scripting

time from 2 files to compare

In first file say first.txt, i have a content say 14:56. In second file, say second.txt i have content say 16:01.... I want to compare if these two times in these 2 files are having a difference of 15 minutes...Can any one please help? (2 Replies)
Discussion started by: manoj.b
2 Replies

6. Shell Programming and Scripting

KSH: Compare variable to $1 in an input file

Hello, I am working with KSH on AIX and I have 2 files generated from different sources... as seen below: FILE1 FILE2 AAA AAA@ABS0001C BBB BBB@ABS0003D CCC CCC@ABS0023A DDD DDD@ABC0145D EEE EEE@ABS0090A FFF FFF@ABS0002A GGG GGG@ABC0150D HHH FILE1 is main main data source,... (4 Replies)
Discussion started by: right_coaster
4 Replies

7. Shell Programming and Scripting

how to compare time in ksh

Hi I have several variables that hold time in the following format: A=01:30 B=23:35 C=22:45 Is there a way / Unix utility which can allow the to compare those time values? Thanks a lot -A (4 Replies)
Discussion started by: aoussenko
4 Replies

8. Shell Programming and Scripting

Compare Last Modified Time across Time Zone

Hi, I'm new to shell script programming, I only have Java programming background. I'm writing a shell script to do file synchronization between 2 machines that located at different time zone area. Both machine were set its time zone according to its geographical location (Eg: server is at... (1 Reply)
Discussion started by: python
1 Replies

9. Shell Programming and Scripting

Can we compare time ...

Hi ... Is there a possibility that timings from two files be compared?? If i have a set of files in a folder and i want to get the files only upto a particular time. eg: If i have the files staff 2388 Oct 3 04:33 x.ksh staff 3628 Oct 3 06:57 1.ksh staff 32383... (1 Reply)
Discussion started by: sparks
1 Replies

10. UNIX for Dummies Questions & Answers

Need to get 4 Hrs back time and compare with successive time

Hi all, I am working on a script in which i need to get 4 hrs back time from the current time which i got from this perl function : `perl -e 'print localtime(time() - 14400) . "\n"'` now i need to get this in a loop and increment that time by 15 minutes i.e i=900(=15minutes) `perl... (2 Replies)
Discussion started by: maanik85
2 Replies
Login or Register to Ask a Question