Sponsored Content
Top Forums Shell Programming and Scripting Extract info and do algebra on it by sed or awk Post 302766305 by hayreter on Monday 4th of February 2013 02:20:49 PM
Old 02-04-2013
I think, the code does not pick the correct rows !!!
The algebraic calculation has to be done on two consecutive rows
satisfying the given conditions. what do you think?

---------- Post updated at 01:20 PM ---------- Previous update was at 01:06 PM ----------

Ok let me give you the real deal Smilie
here is a real sample from my file;
Code:
"83586",21,-1,0,0,501,502,0.00000000000E+00,0.00000000000E+00,0.40493970075E+03,0.40493970075E+03,0.00000000000E+00,0.,-1.
"83587",21,-1,0,0,502,503,0.00000000000E+00,0.00000000000E+00,-0.13690511920E+04,0.13690511920E+04,0.00000000000E+00,0.,1.
"83588",6,1,1,2,501,0,0.16602324784E+02,0.21173242262E+03,0.83772415324E+02,0.28584624109E+03,0.17200000000E+03,0.,1.
"83589",-6,1,1,2,0,503,0.21296508725E+03,-0.34724062240E+03,-0.11031327863E+04,0.11884511443E+04,0.17200000000E+03,0.,1.
"83590",25,1,1,2,0,0,-0.22956741204E+03,0.13550819978E+03,0.55248879711E+02,0.29969350735E+03,0.12530000305E+03,0.,0.
"83591",21,-1,0,0,503,502,0.00000000000E+00,0.00000000000E+00,0.23112128409E+03,0.23112128409E+03,0.00000000000E+00,0.,-1.
"83592",21,-1,0,0,501,503,0.00000000000E+00,0.00000000000E+00,-0.60107765286E+03,0.60107765286E+03,0.00000000000E+00,0.,-1.
"83593",6,1,1,2,501,0,-0.17819622689E+03,-0.96491143735E+02,-0.31619254612E+03,0.41306919798E+03,0.17200000000E+03,0.,1.
"83594",-6,1,1,2,0,502,0.15029873573E+03,-0.61138110558E+01,0.36878029061E+02,0.23145426692E+03,0.17200000000E+03,0.,1.
"83595",25,1,1,2,0,0,0.27897491154E+02,0.10260495479E+03,-0.90641851705E+02,0.18767547204E+03,0.12530000305E+03,0.,0.

according to this sample I changed the code as this;
Code:
awk -F, 'NR>1&&$2==6{f=1;split($0,A,",");}f==1&&$2==-6{ print sqrt((a[8]+$8)^2+(a[9]+$9)^2+(a[10]+$10)^2+(a[11]+$11)^2);f=0;}' filename

for this part of file, code gives 2 numbers 1671.9 and 278.493 respectively, but if you calculate yourself
the numbers come out as 710.446 and 1797.58. The numbers that I get are from rows "83588","83589" and "83593","83594"
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extract using sed/awk - need help? Please!!

Need help..not sure how to use with awk or sed I want to take data from the notification.$$ file and assign the data to variable "group". Not sure how to do it. The data I want to extract from the notification.$$ is on the first line of the file ..right after the (notice): NetWorker... (5 Replies)
Discussion started by: gzs553
5 Replies

2. Shell Programming and Scripting

Extract some characters with SED or AWK

Hi, I have the following example string: today_is_a_good_day.txt The character "_" inside the string can sometimes be more or less. The solution for every string equal the count of "_" should be alway the rest after the last underline character. Result: day.txt I want to use awk... (5 Replies)
Discussion started by: climber
5 Replies

3. Shell Programming and Scripting

how to extract info from a file using awk

Dear all I have a file call interfaces.txt Filename: interfaces.txt How can I extract the information at below? ABC_DB_001 hostname1 20901 ABC_DB_002 hostname2 20903 ABC_DB_003 hostname3 20905 Currently I am using a very stupid method grep ^ABC interfaces.txt > name.txt grep... (3 Replies)
Discussion started by: on9west
3 Replies

4. Shell Programming and Scripting

[sed/awk] find info and replace

Hi :) I have some problems with "FOR"... I have a text file in this format: name1 www.link1/random_number name2 www.link2/random_number name3 www.link3/random_number ... (Names and info changes) Now, I need: (4 Replies)
Discussion started by: aspire
4 Replies

5. UNIX for Dummies Questions & Answers

Using awk/sed to extract text between Strings

Dear Unix Gurus, I've got a data file with a few hundred lines (see truncated sample)... BEGIN_SCAN1 TASK_NAME=LA48 PDD Profiles PROGRAM=ArrayScan 1.00 21.220E+00 2.00 21.280E+00 END_DATA END_SCAN1 BEGIN_SCAN2 TASK_NAME=LA48 PDD Profiles 194.00 2.1870E+00 ... (5 Replies)
Discussion started by: tintin72
5 Replies

6. Shell Programming and Scripting

Using AWK BEGIN to extract file header info into variables

Hi Folks, I've searched for this for quite a while, but can't find any solution - hope someone can help. I have various files with standard headers. eg. <HEADER> IP: 1.2.3.4 Username: Joe Time: 12:00:00 Date: 23/05/2010 </HEADER> This is a test and this part can be any size... (6 Replies)
Discussion started by: damoske
6 Replies

7. Shell Programming and Scripting

Extract word from text (sed,awk, etc...)

Hello, I need some help extracting the number after the RBA e.g 15911688 from the below block of text (e.g: grep RBA |sed .......). The code should be valid for blocks if text generated at different times as well and not for the below text only. ... (2 Replies)
Discussion started by: drbiloukos
2 Replies

8. Shell Programming and Scripting

Extract a substring using SED/AWK

Hi All, I have a log file in which name and version of applications are coming in the following format name It may look like following, based on the name of the application and version: XYZ OR xyz OR XyZ OR xyz I want to separate out the name and version and store them into variables.... (4 Replies)
Discussion started by: bhaskar_m
4 Replies

9. Shell Programming and Scripting

Awk/sed HTML extract

I'm extracting text between table tags in HTML <th><a href="/wiki/Buick_LeSabre" title="Buick LeSabre">Buick LeSabre</a></th> using this: awk -F "</*th>" '/<\/*th>/ {print $2}' auto2 > auto3 then this (text between a href): sed -e 's/\(<*>\)//g' auto3 > auto4 How to shorten this into one... (8 Replies)
Discussion started by: p1ne
8 Replies

10. Shell Programming and Scripting

Help with awk to extract additional info

Hi I use multipath linux command to get LUNs info and find out if any failed. # multipath -ll >/tmp/mpfail # cat /tmp/mpfail multipath.conf line 109, invalid keyword: user_friendly_names multipath.conf line 153, invalid keyword: user_friendly_names multipath.conf line 193, invalid... (4 Replies)
Discussion started by: prvnrk
4 Replies
RDF::Query::Algebra::Sequence(3pm)			User Contributed Perl Documentation			RDF::Query::Algebra::Sequence(3pm)

NAME
RDF::Query::Algebra::Sequence - Algebra class for a sequence of algebra operations VERSION
This document describes RDF::Query::Algebra::Sequence version 2.908. METHODS
Beyond the methods documented below, this class inherits methods from the RDF::Query::Algebra class. "new ( @patterns )" Returns a new Sequence structure. "construct_args" Returns a list of arguments that, passed to this class' constructor, will produce a clone of this algebra pattern. "patterns" Returns a list of patterns belonging to this sequence. "sse" Returns the SSE string for this algebra expression. "as_sparql" Returns the SPARQL string for this algebra expression. "as_hash" Returns the query as a nested set of plain data structures (no objects). "type" Returns the type of this algebra expression. "referenced_variables" Returns a list of the variable names used in this algebra expression. "potentially_bound" Returns a list of the variable names used in this algebra expression that will bind values during execution. "definite_variables" Returns a list of the variable names that will be bound after evaluating this algebra expression. "clone" "bind_variables ( \%bound )" Returns a new algebra pattern with variables named in %bound replaced by their corresponding bound values. AUTHOR
Gregory Todd Williams <gwilliams@cpan.org> perl v5.14.2 2012-01-31 RDF::Query::Algebra::Sequence(3pm)
All times are GMT -4. The time now is 12:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy