Sponsored Content
Top Forums Shell Programming and Scripting [Perl] Same entries in file, but treat them different. Post 302521602 by mirni on Wednesday 11th of May 2011 08:17:28 PM
Old 05-11-2011
What exactly is your problem?
If you just need to measure the times between the lines, this should work:
Code:
$ perl -F, -ane 'if($lastTime==0){ #first line; initialize 
  $lastTime=$F[1];
  $lastWhat=$F[$#F]; #last field
  next;
} 
$diff=$F[1]-$lastTime; #difference in seconds
($lastWhat=$F[$#F])=~s/STATUS: //;   #get rid of 'STATUS: ' 
$lastWhat=~s/\.\n//;   #strip trailing period and newline
$lastTime=$F[1];  #remember the time 
print "Event \"$lastWhat\" took $diff seconds\n";
' log 
Event "Starting Table table loading" took 459 seconds
Event "Sorting of Table1 data file started" took 3350 seconds
Event "Starting Table table loading" took 446 seconds
Event "Sorting of Table2 data file started" took 3428 seconds
Event "Starting Table table loading" took 323 seconds
Event "Creating Table indexes" took 2743 seconds
Event "Analyzing table Table" took 2953 seconds
Event "End of table_load" took 483 seconds

But I might have misunderstood what you're trying to accomplish....
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - treat multiple delimiters as one

Is there anyway to get awk to treat multiple delimiters as one? Particularly spaces... (6 Replies)
Discussion started by: peter.herlihy
6 Replies

2. Shell Programming and Scripting

How to get the difference between dates?Can i treat as string?

Hi All , I have an output value with two columns like this... Days User 10 A 500 B 1 C How i can compare the first column value and passing the user name as parameter? For example : while read -r days If (days<=30) ; then value=days/30 x100 ... (3 Replies)
Discussion started by: EDBGSK
3 Replies

3. Shell Programming and Scripting

while read loop w/ a nested if statement - doesn't treat each entry individually

Hi - Trying to take a list of ldap suffixes in a file, run an ldapsearch command on them, then run a grep command to see if it's a match, if not, then flag that and send an email alert. The list file (ldaplist) would look like - *********** o=company a o=company b *********** **... (7 Replies)
Discussion started by: littlefrog
7 Replies

4. UNIX for Dummies Questions & Answers

make script treat * as a regular character

I need a script that reads the out put of a command (softwareupdate --list) and will tally up the number of asterisks in the output and tell me how many there were. How do I go about getting my script to treat asterisks as a regular character and not a wildcard or some other operator? (8 Replies)
Discussion started by: glev2005
8 Replies

5. UNIX for Dummies Questions & Answers

doubt to treat plaintext script

Hi everyone! first of all thank you all for the forum. My question is, is there a bash or java program, which addresses the existing text in the html that is visible in the web page for editing by another string, eg name1: flakjsdlñfjas Name of father: fdfjaksdfjskdfsd Well it... (1 Reply)
Discussion started by: xavilito
1 Replies

6. Shell Programming and Scripting

Perl's buffered I/O is causing me to miss latest log file entries in log colorizer. How to fix?

I've been finding myself using a log file colorizer written in perl to reformat and colorize the output from many different programs. Mainly, however, I use it to make the output from "tail -f" commands more readable. The base perl script I use is based on "colorlogs.pl" available from the... (1 Reply)
Discussion started by: rcsteiner
1 Replies

7. Shell Programming and Scripting

awk script modification - treat certain files differently

awk 'BEGIN{OFS=","} FNR == 1 {if (NR > 1) {print fn,fnr,nl} fn=FILENAME; fnr = 1; nl = 0} {fnr = FNR} /UNUSUAL/ && /\.gz/ ~ /FILENAME/ {nl++} <'{system ("gunzip -cd FILENAME")}' END ... (2 Replies)
Discussion started by: SkySmart
2 Replies

8. Shell Programming and Scripting

Treat Command Output as a File

Hi. Before I've post this question, I have spent hours looking for the solutions but to no avail. Because I think it is possible but I just don't know what is the right keyword to search for. Ok, basically what I want to achieve is really simple. It's just that I don't want to write... (20 Replies)
Discussion started by: aimy
20 Replies
GLSWEEP(1)						      General Commands Manual							GLSWEEP(1)

NAME
glsweep - a program generating log sweep and inverse filter. SYNOPSIS
glsweep [parameters] sweepfile inversefile Usage: glsweep rate amplitude hzstart hzend duration silence leadin leadout sweepfile inversefile Example: glsweep 44100 0.5 10 21000 45 2 0.05 0.005 sweep.pcm inverse.pcm DESCRIPTION
This manual page documents briefly the glsweep program. This manual page was written for the Debian distribution because the original pro- gram does not have a manual page. glsweep is program to perform accurate time aligned impulse response measurements. glsweep is based on the log sweep method for impulse response measurement, which is one of the most accurate, especially for acoustic mea- surements. This method is based on a special signal, which is a logarithmic sinusoidal sweep, that need to be reproduced through the system under test, and an inverse filter, which, when convolved with the measured log sweep, gives back the impulse response of the system. The output format is the usual raw file with 32 bit IEEE floating point samples. If you need to convert the sweep generated using the exam- ple above to a 16 bit mono WAV file you can use SoX with a command line like this one: sox -t f32 -r 44100 -c 1 sweep.pcm -t wav -c 1 sweep.wav PARAMETERS
rate: reference sample rate amplitude: sweep amplitude hzstart: sweep start frequency hzend: sweep end frequency duration: sweep duration in seconds silence: leading and trailing silence duration in seconds leadin: leading window length as a fraction of duration leadout: trailing window length as a fraction of duration sweepfile: sweep file name inversefile: inverse sweep file name Refer to html documentation for more details. SEE ALSO
sox(1). AUTHOR
This manual page was written by Jaromir Mike <mira.mikes@seznam.cz>, for the Debian project (but may be used by others). August 30, 2011 GLSWEEP(1)
All times are GMT -4. The time now is 11:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy