![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Arithmetic on timestamps | balireddy_77 | Shell Programming and Scripting | 3 | 03-18-2009 10:02 PM |
| timestamps | chriss_58 | Shell Programming and Scripting | 1 | 05-30-2008 06:12 AM |
| how to find difference of 2 timestamps in secs? | Alecs | UNIX for Dummies Questions & Answers | 0 | 03-24-2008 12:36 PM |
| Difference between two timestamps | raman1605 | SUN Solaris | 8 | 08-05-2007 08:54 PM |
| Unix timestamps | hamsasal | UNIX for Dummies Questions & Answers | 3 | 09-07-2006 10:03 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Difference between two timestamps Contd..
There was this thread earlier with the same name and the solution provided was excellent. Here is the solution to find diffrenc between two timestamp Code:
$ cat timestamp
#! /usr/bin/ksh
echo enter first time stamp
read TIME1
echo enter second time stamp
read TIME2
H1=${TIME1%:+([0-9])}
M1=${TIME1#+([0-9]):}
H2=${TIME2%:+([0-9])}
M2=${TIME2#+([0-9]):}
H1=${H1#0}
M1=${M1#0}
H2=${H2#0}
M2=${M2#0}
((MAM1=H1*60+M1))
((MAM2=H2*60+M2))
((MAM1>MAM2)) && ((MAM2=MAM2+1440))
((diff=MAM2-MAM1))
echo diff = $diff
my problem is, i have excecuted the same code in in AIX box and it works well, but while running this code in solaris i get the following error $ ./Timestamp.sh Start time: 00:13:01 End Time : 06:13:26 ./Timestamp.sh: syntax error at line 18: `H1=${TIME1%:+' unexpected Since the logic used here is excellent, but the problem is due to the Solaris,Any help will be much appreciated on how the H1=${TIME1%:+([0-9])} statement can be changed to run on solaris. Thanks in advance
|
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|