Sponsored Content
Top Forums Shell Programming and Scripting Computing difference based on line contents Post 302795077 by ncwxpanther on Wednesday 17th of April 2013 09:44:19 AM
Old 04-17-2013
Quote:
Originally Posted by hanson44
It's kind of unclear to me what you are trying to do. Maybe others can understand. If nobody else responds, could you restate the problem more clearly?

Apologies for the fuzziness nature of my question. Ill try to restate it below.

I need each tab dilemented column (2 through 14) to be subtracted from the same tab dilemented column in the line that contains 0008.

So from the below code
Code:
XXXXXXXXX0008   39.5   43.8   51.7   59.5   67.7   75.2   78.9   77.8   71.7   60.5   50.7   42.6   60.0
XXXXXXXXX1895   38.5   33.0   50.0   60.7   67.2   77.2   78.5   79.2   76.8   56.0   50.4   43.4   59.2

The output would be
Code:
XXXXXXXXX0008   39.5   43.8   51.7   59.5   67.7   75.2   78.9   77.8   71.7   60.5   50.7   42.6   60.0
XXXXXXXXX1895   -1.0   -10.8   -1.7     1.2   -0.5     2.0    -0.4     1.4     4.9......

---------- Post updated at 09:44 AM ---------- Previous update was at 08:32 AM ----------

Quote:
Originally Posted by RudiC
Applying the usually needed portion of clairvoyance, I'd propose
Code:
awk     '               {val = substr($1,length($1)-3,4) + 0}
         val == 0008    {n = split ($0, DI)}
         val >  1894 &&
         val <  2013    {for (i=2; i<=n; i++) $i-=DI[i]; $0 = $0}
         1
        ' OFS="   " file
XXXXXXXXX0007   38.3   42.6   51.3   60.1   67.7   75.1   78.4   77.6   71.6   60.2   50.8   42.3   59.7
XXXXXXXXX0008   39.5   43.8   51.7   59.5   67.7   75.2   78.9   77.8   71.7   60.5   50.7   42.6   60.0
XXXXXXXXX1895   -1   -10.8   -1.7   1.2   -0.5   2   -0.4   1.4   5.1   -4.5   -0.3   0.8   -0.8
XXXXXXXXX1896   1.5   0.1   -3.8   7.3   6.5   0.4   1   3.7   0.8   -0.5   3   0.8   1.7

RudiC

Thanks! That seems to work, but what is the syntax to preserve the decimal. I need to keep the precision to the tenths.

XXXXXXXXX1895 -1.0 -10.8 -1.7 1.2 -0.5 2.0 -0.4 1.4 5.1 -4.5 -0.3 0.8 -0.8
 

9 More Discussions You Might Find Interesting

1. Solaris

make sure HA server no difference contents

hello there. I would like to know how can I make sure HA server have exactly same contents. for example at timestamp 1 (before start install oracle product ) assume the both server have exactly same contents. at timestamp 2 I install Oracle product at both server, hope... (3 Replies)
Discussion started by: qyxiell
3 Replies

2. Programming

What is the difference between console-based and xwindow-based application?

Hi everyone, What is the difference between console-based and Xwindow-based application? Can I say the application working well in Xwindows can work in console? Can I say the application working well in console cann't work in Xwindow perhaps. Eg, ncurses is console-based and Imlib2 is... (4 Replies)
Discussion started by: liuyan03
4 Replies

3. Shell Programming and Scripting

Merging files based on the contents

Hi, I have a file f1 having the contents as below select (<condn>) from dual I have another file f2 having the contents as below 1, 2, 3 I want to replace <condn> in f1 with the contents of f2 I tried using sed like this sed "s:<condn>:`cat f2`:g" f1 The above command resulted in sed:... (3 Replies)
Discussion started by: mr_manii
3 Replies

4. Shell Programming and Scripting

Manipulating word based off of contents

Hello everyone, my first post here, please feel free to inform me if my question can be better formatted so my future posts may be more clear. I have a large text file which I need parsed in one specific way, I have done the rest of the processing, I am simply lacking the last aspect of such. ... (8 Replies)
Discussion started by: ryanfx
8 Replies

5. Shell Programming and Scripting

move contents from one file to another based on line number or content

I want a script that will move everything beyond a certain line number or beyond a certain content word into another file. For example, if file A has this: first line second line third line forth line fifth line sixth line I want to run a script that will move everything beyond the third... (4 Replies)
Discussion started by: robp2175
4 Replies

6. Shell Programming and Scripting

how to read the contents of two files line by line and compare the line by line?

Hi All, I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Discussion started by: mjavalkar
4 Replies

7. Shell Programming and Scripting

File comparison based on contents

Hi I have 2 files 1.del ---- 1,2,3,4,5 1,2,3,4,4 1,1,1,1,2 2.del ---- 1,2,3,4,5 1, 1,2,3,4,4 1,1,1,1,2 I need to compare the above two files in unix, as in the output should only tell the difference in contents as I should get only the line 1 ( from 2.del) , rest all lines are... (4 Replies)
Discussion started by: Ethen561
4 Replies

8. Shell Programming and Scripting

Help with computing median line by line of several files.

I have several files which look like this. The files are much longer than this, I have just cut out the data and there are hundreds of these files file 1 0.00 5.905 0.05 5.740 0.10 5.570 0.15 5.440 0.20 5.310 0.25 5.185 0.30 5.075 0.35 5.897 0.40 ... (3 Replies)
Discussion started by: malandisa
3 Replies

9. Shell Programming and Scripting

How to remove a line based on contents of the first column?

Good day all. Using basic UNIX/Linux tools, how would you delete a line based on a character found in column 1? For example, if the CITY name contains an 'a' or 'A', delete the line: New York City; New York Los Angeles; California Chicago; Illinois Houston; Texas Philadelphia;... (3 Replies)
Discussion started by: BRH
3 Replies
Locale::Codes::LangFam(3)				User Contributed Perl Documentation				 Locale::Codes::LangFam(3)

NAME
Locale::Codes::LangFam - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangFam; $lext = code2langfam('apa'); # $lext gets 'Apache languages' $code = langfam2code('Apache languages'); # $code gets 'apa' @codes = all_langfam_codes(); @names = all_langfam_names(); DESCRIPTION
The "Locale::Codes::LangFam" module provides access to standard codes used for identifying language families, such as those as defined in ISO 639-5. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 639-5 language family codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language families. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langfam('apa','alpha'); $lext = code2langfam('apa',LOCALE_LANGFAM_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from ISO 639-5 such as 'apa' for Apache languages. This is the default code set. ROUTINES
code2langfam ( CODE [,CODESET] ) langfam2code ( NAME [,CODESET] ) langfam_code2code ( CODE ,CODESET ,CODESET2 ) all_langfam_codes ( [CODESET] ) all_langfam_names ( [CODESET] ) Locale::Codes::LangFam::rename_langfam ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangFam::add_langfam ( CODE ,NAME [,CODESET] ) Locale::Codes::LangFam::delete_langfam ( CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_alias ( NAME ,NEW_NAME ) Locale::Codes::LangFam::delete_langfam_alias ( NAME ) Locale::Codes::LangFam::rename_langfam_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::delete_langfam_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.loc.gov/standards/iso639-5/id.php ISO 639-5 . AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.3 2013-02-27 Locale::Codes::LangFam(3)
All times are GMT -4. The time now is 07:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy