The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Average completion time calculation? Seawall UNIX for Dummies Questions & Answers 5 05-20-2008 07:13 AM
MD5 hash calculation zedex High Level Programming 4 02-24-2007 02:37 AM
awk calculation kekanap Shell Programming and Scripting 4 11-17-2006 07:39 AM
change time interval for /proc/loadavg calculation Rakesh Ranjan High Level Programming 2 05-12-2006 05:48 AM
script execution time calculation johnsonbryce Shell Programming and Scripting 9 02-25-2006 01:33 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-18-2005
liux99 liux99 is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 3
time calculation

Hi,

I have start time as a string like 06:04:01 and end time like 06:05:01
i need do a simple math to get the duration. What is the best way
to do this in Korn Shell scripting? Thanks
  #2 (permalink)  
Old 08-18-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,246
Convert everything to seconds and subtract

Code:
echo 06:04:01 | awk -F: '{ print $1*360+$2*60+$3}'

  #3 (permalink)  
Old 08-18-2005
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,411
Typo..
Code:
echo 06:04:01 | awk -F: '{ print $1*3600+$2*60+$3}'

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:18 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0