Find time difference between two consecutive lines in same file.
Hello
I have a file in following format:
IV 08:09:07
NM 08:12:01
IC 08:12:00
MN 08:14:20
NM 08:14:15
I need a script to compare time on each line with previous line and show the inconsecutive line. Ex.:
08:12:00
08:14:15
A better way will be a message in this form:
“IC has 1 second difference on 08:12:00 time
NM has 5 second difference on 08:14:15 time”
But first example will be more than enough.
How i can compare each line whit previews line? I tried this script:
but it doesn’t work in line 3. Is a syntax problem or is an impossible command. I don’t know. I’m new in this. I even try to make a variable name, variable but again I’m stuck in line 3 on syntax or in “impossibliness” problem:
It must be an “eval” expression somewhere but “indirect variable reference” is way over my head right now. I have a felling that all can be done very easily but I can’t see how .
Thanks in advance for your time.
Hello Friends,
I want to write a script for the following:
nlscux62:tibprod> grep "2008 Apr 30 01:" SA_EHV_SPEED_SFC_IN_03-SA_EHV_SPEED_SFC_IN_03-2.log | grep -i post | more
2008 Apr 30 01:01:23:928 GMT +2 SAPAdapter.SA_EHV_SPEED_SFC_IN_03-SA_EHV_SPEED_SFC_IN_03-2 Info AER3-000095 IDOC... (2 Replies)
Hi guru's,
Am new to shell scripting.
I am getting the below o/p from the oracle database, when I fire a query.
ID JOB_ID ELAPSED_TIME FROM TO
----- ------ ------------------- -------- --------
62663 11773 01/06/2009 09:49:13 SA CM
62664 11773 ... (4 Replies)
Hi,
I have a file with one column data (sample below) and I am trying to write a shell script to calculate the difference between consecutive data valuse i.e
Var = Ni -N(i-1)
0.3141
-3.6595
0.9171
5.2001
3.5331
3.7022
-6.1087
-5.1039
-9.8144
1.6516
-2.725
3.982
7.769
8.88 (5 Replies)
Hi guys
I am deleting a unique line from the file and also need to remove the line above it which is NOT unique and servers as a record separator. Here is an example:
#
101 803E 823F 8240
#
102 755f 4F2A 4F2B
#
290 747D 0926 0927
#
999 8123 813E ... (5 Replies)
I have a file wich contains time formats and i need to get the time difference
TIME1 TIME2
==================================
20120624192555.6Z 20120624204006.5Z
which means first date 2012/6/24 19:25:55,second date 2012/6/24 20:40:06 so when i get the time... (1 Reply)
I have a file wich contains time formats and i need to get the time difference
TIME1 TIME2
=============== ===================
20120624192555.6Z 20120624204006.5Z
which means first date 2012/6/24 19:25:55,second date 2012/6/24 20:40:06 so when i get the time... (23 Replies)
Hi All :o,
I have some log files which contains these informations:
2013-04-24 09:11:34.018 INFO XXXXXXXXXXXX
2013-04-24 09:11:34.029 INFO YYYYYYYYYYYY
2013-04-24 09:11:34.039 INFO ZZZZZZZZZZZZZZZ
2013-04-24 09:12:21.295 INFO TTTTTTTTTTTTTTT
2013-04-24 09:12:21.489 INFO... (3 Replies)
I was looking at this script which outputs the two lines which differs less than one sec.
#!/usr/bin/perl -w
use strict;
use warnings;
use Time::Local;
use constant SEC_MILIC => 1000;
my $file='infile';
## Open for reading argument file.
open my $fh, "<", $file or die "Cannot... (1 Reply)
I have a text file with many thousands of lines, a small sample of which looks like this:
InputFile:PS002,003 D -1 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 6 -1 -1 -1 -1 0 509 0
PS002,003 PSQ 0 1 7 18 1 0 -1 1 1 3 -1 -1 ... (5 Replies)
Discussion started by: jvoot
5 Replies
LEARN ABOUT OSX
diff
DIFF(1) User Commands DIFF(1)NAME
diff - compare files line by line
SYNOPSIS
diff [OPTION]... FILES
DESCRIPTION
Compare files line by line.
-i--ignore-case
Ignore case differences in file contents.
--ignore-file-name-case
Ignore case when comparing file names.
--no-ignore-file-name-case
Consider case when comparing file names.
-E--ignore-tab-expansion
Ignore changes due to tab expansion.
-b--ignore-space-change
Ignore changes in the amount of white space.
-w--ignore-all-space
Ignore all white space.
-B--ignore-blank-lines
Ignore changes whose lines are all blank.
-I RE --ignore-matching-lines=RE
Ignore changes whose lines all match RE.
--strip-trailing-cr
Strip trailing carriage return on input.
-a--text
Treat all files as text.
-c-C NUM --context[=NUM]
Output NUM (default 3) lines of copied context.
-u-U NUM --unified[=NUM]
Output NUM (default 3) lines of unified context.
--label LABEL
Use LABEL instead of file name.
-p--show-c-function
Show which C function each change is in.
-F RE --show-function-line=RE
Show the most recent line matching RE.
-q--brief
Output only whether files differ.
-e--ed
Output an ed script.
--normal
Output a normal diff.
-n--rcs
Output an RCS format diff.
-y--side-by-side
Output in two columns.
-W NUM --width=NUM
Output at most NUM (default 130) print columns.
--left-column
Output only the left column of common lines.
--suppress-common-lines
Do not output common lines.
-D NAME --ifdef=NAME
Output merged file to show `#ifdef NAME' diffs.
--GTYPE-group-format=GFMT
Similar, but format GTYPE input groups with GFMT.
--line-format=LFMT
Similar, but format all input lines with LFMT.
--LTYPE-line-format=LFMT
Similar, but format LTYPE input lines with LFMT.
LTYPE is `old', `new', or `unchanged'.
GTYPE is LTYPE or `changed'.
GFMT may contain:
%< lines from FILE1
%> lines from FILE2
%= lines common to FILE1 and FILE2
%[-][WIDTH][.[PREC]]{doxX}LETTER
printf-style spec for LETTER
LETTERs are as follows for new group, lower case for old group:
F first line number
L last line number
N number of lines = L-F+1
E F-1
M L+1
LFMT may contain:
%L contents of line
%l contents of line, excluding any trailing newline
%[-][WIDTH][.[PREC]]{doxX}n
printf-style spec for input line number
Either GFMT or LFMT may contain:
%% %
%c'C' the single character C
%c'OOO'
the character with octal code OOO
-l--paginate
Pass the output through `pr' to paginate it.
-t--expand-tabs
Expand tabs to spaces in output.
-T--initial-tab
Make tabs line up by prepending a tab.
-r--recursive
Recursively compare any subdirectories found.
-N--new-file
Treat absent files as empty.
--unidirectional-new-file
Treat absent first files as empty.
-s--report-identical-files
Report when two files are the same.
-x PAT --exclude=PAT
Exclude files that match PAT.
-X FILE --exclude-from=FILE
Exclude files that match any pattern in FILE.
-S FILE --starting-file=FILE
Start with FILE when comparing directories.
--from-file=FILE1
Compare FILE1 to all operands. FILE1 can be a directory.
--to-file=FILE2
Compare all operands to FILE2. FILE2 can be a directory.
--horizon-lines=NUM
Keep NUM lines of the common prefix and suffix.
-d--minimal
Try hard to find a smaller set of changes.
--speed-large-files
Assume large files and many scattered small changes.
-v--version
Output version info.
--help Output this help.
FILES are `FILE1 FILE2' or `DIR1 DIR2' or `DIR FILE...' or `FILE... DIR'. If --from-file or --to-file is given, there are no restrictions
on FILES. If a FILE is `-', read standard input.
AUTHOR
Written by Paul Eggert, Mike Haertel, David Hayes, Richard Stallman, and Len Tower.
REPORTING BUGS
Report bugs to <bug-gnu-utils@gnu.org>.
COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc.
This program comes with NO WARRANTY, to the extent permitted by law. You may redistribute copies of this program under the terms of the
GNU General Public License. For more information about these matters, see the file named COPYING.
SEE ALSO
The full documentation for diff is maintained as a Texinfo manual. If the info and diff programs are properly installed at your site, the
command
info diff
should give you access to the complete manual.
diffutils 2.8.1 April 2002 DIFF(1)