LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-29-2007, 02:24 AM   #1
farkus888
Member
 
Registered: Oct 2006
Distribution: usually use arch
Posts: 103

Rep: Reputation: 15
comparing timestamps using shell commands


I have a csv file that has a date/time column and a value column and a name column. think a check in check out register at a receptionists desk using one integer in the value column to denote ins and a different integer for outs, always the same 2 integers used.[IE 6 always denotes a check in and 8 always denotes a check out]. I need to be able to take every register for a certain name and determine how long they were there each time they were there. basically,

name,time checked in,time checked in,time checked in...

with a new column for each checkin - checkout cycle. a large part of my problem is that I am not familiar with any command line program that can interpret date/timestamps and I can't seem to think of a proper search string to find one.
 
Old 04-29-2007, 08:05 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
the date -d command can read timestamps. Try info date for more information.
 
Old 04-29-2007, 06:22 PM   #3
farkus888
Member
 
Registered: Oct 2006
Distribution: usually use arch
Posts: 103

Original Poster
Rep: Reputation: 15
Quote:
Display the time and date specified in datestr instead of the current time and date. datestr can be in almost any common format. It can contain month names, time zones, `am' and `pm', `yesterday', `ago', `next', etc.
not sure how that will take 2 time stamps and give me the amount of time that took place between the two. sorry if I wasn't clear enough in my first post.
 
Old 04-30-2007, 02:28 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
If you want to do date/time calcs, you could try this page for ideas http://tldp.org/LDP/abs/html/interna...s.html#TIMEOUT, but it might be easier to use Perl instead...
 
Old 04-30-2007, 06:06 AM   #5
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 735

Rep: Reputation: 76
Hi.
Quote:
Originally Posted by farkus888
not sure how that will take 2 time stamps and give me the amount of time that took place between the two. sorry if I wasn't clear enough in my first post.
Suppose you had a fixed starting time, say sometime in 1970. If you used date to convert both dates to the seconds since that fixed time, then you could subtract the two, and that result should be the time between the two timestamps.

This may require some reading of info date as jim advised, as well as some experimentation, but could be rewarding ... cheers, makyo
 
Old 05-01-2007, 03:13 AM   #6
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
maybe consider using a better tool than shell scripting for this?
like perl or python?
 
Old 05-03-2007, 02:27 AM   #7
farkus888
Member
 
Registered: Oct 2006
Distribution: usually use arch
Posts: 103

Original Poster
Rep: Reputation: 15
sorry for the delay, not working over the weekend. yeah I backed up a step and found unix time in the original log file. I need it to show up next to my name that I don't know perl, python even less. they get recommended for every question I ask. I'm sure I'll have more questions when I get a little farther in to this.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
more shell commands mf5160 Linux - Software 3 03-14-2007 01:41 PM
Comparing Line Per Line In Shell Programming mblames Programming 3 01-18-2007 11:37 PM
about shell commands nesta Linux - Newbie 3 12-12-2006 05:40 PM
Alias or shell script to confirm 'exit' commands from a shell rose_bud4201 Programming 2 03-08-2006 02:34 PM
commands in shell? kalleanka Linux - General 9 02-01-2006 07:38 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration