Subtracting date / timestamps


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Subtracting date / timestamps
# 1  
Old 06-21-2006
Subtracting date / timestamps

I have looked through the forums and found many date / time manipulation tools, but cannot seem to find something that fits my needs for the following.

I have a log file with date time stamps like this:

Jun 21 17:21:52
Jun 21 17:24:56
Jun 21 17:27:59
Jun 21 17:31:03
Jun 21 17:34:07
Jun 21 17:37:10
Jun 21 17:40:14
Jun 21 17:43:18


I need something that "subtracts" the time from the previous entry and
displays the "minutes:seconds" difference.

These should all be around 3 minutes apart, and I am looking for descrepencies.

Any hints on how to do this would be greatly appreciated.

Thanks.,..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Changing CSV files with date . Subtracting date by values

Hi All, I have a CSV file which is as below. Basically I need to take the year column in it and find if the year is >= 20152 . If that is then I should subtract all values by 6. In the below example in description I am having number mentioned as YYWW so I need to subtract those by -5. Whereever... (8 Replies)
Discussion started by: arunkumar_mca
8 Replies

2. Shell Programming and Scripting

Subtracting a date based on ls output

I am trying to achieve to get only the month and the day. Example Feb 5 (as you can see if it is feb 1-9) the space is 2. If it is feb 10-28, the space is only 1. I am trying to right a script that will list a directory and shoot an email if there is an activity in last 7 days. I dont really trust... (5 Replies)
Discussion started by: invinzin21
5 Replies

3. Shell Programming and Scripting

Subtracting months from passed Date

Hi All, I am getting a date from environment variable and want to do some processing by subtracting 2 months from the date passed through the environment variable. I am trying the following syntax : date_var=2014-08-31 date_2M_ago='$date_var+"%d%m%y" --$date_var="2 months ago" '... (3 Replies)
Discussion started by: Rahul Raj
3 Replies

4. UNIX for Dummies Questions & Answers

Subtracting number of days from current date

Hi All, I am using KSH shell and need to subtract n number of days from the current date .. kindly suggest ! Thanks in advance!:) (20 Replies)
Discussion started by: dev.devil.1983
20 Replies

5. UNIX for Dummies Questions & Answers

Subtracting A month from an arbitrary date in UNIX

Hi, Is there a way to subtract a month or at least 30 days from an arbitrary or user inputted date without the GNU date? Example: please Input date: 2011-05-11 then the answer will be 2011-04-11 This code doesn't work: $date -d "2011-05-11 - 1 month" "+%Y%m%d" Thanks (7 Replies)
Discussion started by: erin00
7 Replies

6. Shell Programming and Scripting

Adding/ Subtracting from Date

Hi , How can I add/substruct x number of days with date? For example My_Date=`date` Now I need Hope it's clear. (2 Replies)
Discussion started by: Anupam_Halder
2 Replies

7. Shell Programming and Scripting

SQL one liner for subtracting 1 from date

I got a statement like below to subtract 1 from given date using teradata. I am looking for a one line unix command to perform the same. select 'parse_this_record', (DATE '${FILE_DATE}' - 1) (FORMAT 'YYYY-MM-DD'); Input: 2012-02-21 Expected Output: 2012-02-20 PS: One liner because I am... (2 Replies)
Discussion started by: siteregsam
2 Replies

8. UNIX for Dummies Questions & Answers

Static date adding and subtracting years

Hi Gurus! I have a static date in a YYYYMMDD format; and I want get the date 2 years in the past and 2 years in the future. static_date=20010203 old_date=$static_date - 3 years future_date=$static_date + 2 years I was only able to research on dates that are current and not on static... (3 Replies)
Discussion started by: kokoro
3 Replies

9. UNIX for Dummies Questions & Answers

adding or subtracting days in the o/p of date

how can we add or subtract days from the output of date command in unix... like if i want to subtract a day from the result of date command like this.. v_date=`date +%Y%m%d` this wud give me 20080519 now i want to subtract one day from this.. so tht it wud give me 20080518.. how do i do... (1 Reply)
Discussion started by: St.Fartatric
1 Replies

10. Shell Programming and Scripting

subtracting a days from current date

Hi i am trying to subtract days from current date. For example todays date is 10/03/2006. If i subtract 2 days it should give 8/03/2006. I am also trying to find the access date of a file in dd/mm/yyyy format. Can any one please help in how to do this. Ramesh (1 Reply)
Discussion started by: rameshspal
1 Replies
Login or Register to Ask a Question
fwtmp(1M)						  System Administration Commands						 fwtmp(1M)

NAME
fwtmp, wtmpfix - manipulate connect accounting records SYNOPSIS
/usr/lib/acct/fwtmp [-ic] /usr/lib/acct/wtmpfix [file...] DESCRIPTION
fwtmp reads from the standard input and writes to the standard output, converting binary records of the type found in /var/adm/wtmpx to formatted ASCII records. The ASCII version is useful when it is necessary to edit bad records. wtmpfix examines the standard input or named files in utmpx format, corrects the time/date stamps to make the entries consistent, and writes to the standard output. A hyphen (-) can be used in place of file to indicate the standard input. If time/date corrections are not performed, acctcon(1M) will fault when it encounters certain date-change records. Each time the date is set, a pair of date change records are written to /var/adm/wtmpx. The first record is the old date denoted by the string "old time" placed in the line field and the flag OLD_TIME placed in the type field of the utmpx structure. The second record speci- fies the new date and is denoted by the string new time placed in the line field and the flag NEW_TIME placed in the type field. wtmpfix uses these records to synchronize all time stamps in the file. In addition to correcting time/date stamps, wtmpfix will check the validity of the name field to ensure that it consists solely of alphanu- meric characters or spaces. If it encounters a name that is considered invalid, it will change the login name to INVALID and write a diag- nostic to the standard error. In this way, wtmpfix reduces the chance that acctcon will fail when processing connect accounting records. OPTIONS
-ic Denotes that input is in ASCII form, and output is to be written in binary form. FILES
/var/adm/wtmpx history of user access and administration information ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWaccu | +-----------------------------+-----------------------------+ SEE ALSO
acctcom(1), ed(1), acct(1M), acctcms(1M), acctcon(1M), acctmerg(1M), acctprc(1M), acctsh(1M), runacct(1M), acct(2), acct.h(3HEAD), utmpx(4), attributes(5) System Administration Guide: Basic Administration SunOS 5.10 22 Feb 1999 fwtmp(1M)