Sponsored Content
Top Forums Shell Programming and Scripting awk math operation on two files Post 302607886 by killerbee on Thursday 15th of March 2012 02:44:20 PM
Old 03-15-2012
awk math operation on two files

Hi, I need your help. I've got two files and i need to add 2nd line after occurrence of "Group No X" from data2.txt to 3rd line (after occurrence of "Group No X") from data1.txt. There is the same number of "Groups" in both files and the numbers of groups have the same pattern.
data1.txt
Code:
Group No 1
23           23             
24           24    
25           25             
26           26             
27           27             
Group No 2
13           13             
14           14             
15           15             
16           16             
17           17
Group No 3
3             3             
4             4             
5             5             
6             6             
7             7

data2.txt
Code:
Group No 1
1000             1000             
2000             2000             
3000             3000             
Group No 2
100               100
200               200
300               300
Group No 3
10000           10000
20000           20000
30000           30000

I need to get output that looks like:
Code:
Group No 1
23             23
24             24             
2025         2025             
26             26             
27             27                
Group No 2
13             13             
14             14             
215           215             
16             16             
17             17             
Group No 3
3               3             
4               4             
20005       20005             
6               6             
7               7

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

awk logic and math help

Hi, My file has 2 fields and millions of lines. variableStep chrom=Uextra span=25 201 0.5952 226 0.330693 251 0.121004 276 0.0736858 301 0.0646982 326 0.0736858 401 0.2952 426 0.230693 451 0.221004 476 0.2736858 Each field either has a... (6 Replies)
Discussion started by: wyarosh
6 Replies

2. Shell Programming and Scripting

Need help with AWK math

I am trying to do some math, so that I can compare the average of six numbers to a variable. Here is what it looks like (note that when I divide really big numbers, it isn't a real number): $ tail -n 6 named.stats | awk -F\, '{print$1}' 1141804 1140566 1139429 1134210 1084682 895045... (3 Replies)
Discussion started by: brianjb
3 Replies

3. Shell Programming and Scripting

awk math and csv output

Hi I have this list 592;1;Z:\WB\DOCS;/FS3_100G/FILER112/BU/MPS/DOCS;;;;\\FILER112\BUMPS-DOCS\;580,116,544,878 Bytes;656,561 ;77,560 592;2;Z:\WB\FOCUS;/FS3_100G/FILER112/BU/MPS/FOCUS;;;;\\FILER112\BUMPS-FOCUS\;172,430 Bytes;6 ;0 ... (12 Replies)
Discussion started by: nakaedu
12 Replies

4. Shell Programming and Scripting

awk in horizontal and vertical math

Based on input ail,UTT,id1_0,COMBO,21,24,21,19,85 al,UTHAST,id1_0,COMBO,342,390,361,361,1454 and awk code as awk -F, '{ K=0; for(i=NF; i>=(NF-4); i--) { K=K+$i; J=J+$i;} { print K } } END { for ( l in J ) printf("%s ",J); }' I'm trying to add columns and lines in single line. line... (6 Replies)
Discussion started by: busyboy
6 Replies

5. Shell Programming and Scripting

awk --> math-operation in a array

Hi main object is categorize the difference of data-values (TLUFT02B - TLUFT12B). herefor i read out data-files which are named acording to the timeformat yyyymmddhhmm. WR030B 266.48 Grad 0 WR050B 271.46 Grad 0 WR120B 268.11 Grad 0 WV030B 2.51 m/s ... (6 Replies)
Discussion started by: IMPe
6 Replies

6. Shell Programming and Scripting

awk --> math-operation in data-record and joining with second file data

Hi! I have a pretty complex job - at least for me! i have two csv-files with meassurement-data: fileA ...... (2 Replies)
Discussion started by: IMPe
2 Replies

7. Shell Programming and Scripting

Count math using awk

Hi expert, I have log : TOTAL-TIME : 2125264636 DATA-BYTES-DOWN : 3766111307032 DATA-BYTES-UP : 455032157567 DL = (3766111307032/2125264636)/1024 = 1.73 UL = (455032157567/2125264636)/1024 = 0.21 I want the result : TOTAL = 1.94 ... (4 Replies)
Discussion started by: justbow
4 Replies

8. Shell Programming and Scripting

Math count %memory using awk

Hi expert, i have log this: Memory: 74410384 Memory: 75831176 Memory: 77961232 Memory: 77074656 Memory: 76086160 Memory: 77128592 Memory: 78045384 Memory: 76696040 Memory: 72401176 Memory: 72520016 Memory: 72137016 Memory: 73175832 Memory: 73034528 Memory: 71770736 Memory:... (4 Replies)
Discussion started by: justbow
4 Replies

9. Shell Programming and Scripting

[awk] Math & Bold-Font?

Heya There is a script which has presets stored in a tab-seperated file. That script also has $help_text, which will be shown when called with invalid arguments or -h. So i do need to have that file ready, so the help text can get the values out of the file, and print it with the $help_text.... (17 Replies)
Discussion started by: sea
17 Replies

10. UNIX for Beginners Questions & Answers

Copy last few lines of a file, perform math operation and iterate further

Hi, I am trying to generate a data of following order: 4 0 1 642 643 4 642 643 1283 1284 4 1283 1284 1924 1925 4 1924 1925 2565 2566 4 2565 2566 3206 3207 4 3206 3207 3847 3848 4 3847 3848 4488 4489 4 4488 4489 5129 5130 ---------------------- 4 1 2 643 644 4 643 644 1284... (6 Replies)
Discussion started by: SaPa
6 Replies
Fax Formats(1)						      General Commands Manual						    Fax Formats(1)

       This page, part of the Netpbmuser'sguide(1) , describes FAX formats in relation to Netpbm facilities.

       The  ITU  (formerly CCITT) publishes standards for operation of fax machines (the idea is to provide a way to be sure that a fax machine is
       able to receive a fax sent by another).	These standards incidentally specify graphics file formats -- a protocol for representing a visual
       image in sequences of bits.

       The  two  relevant  standards  are  called Group 3 (G3) and Group 4 (G4) (Groups 1 and 2 are analog standards no longer in use).  Virtually
       every fax machine in existence conforms at least generally to at least one of these standards.

       The standard for Group 3 fax is defined in ITU Recommendation T.4.  In the U.S., that is implemented by EIA standards EIA-465 and  EIA-466.
       These  standards  cover more than the file format as well, including how to transmit bits over a telephone line and procedures for handling
       document transmissions.

       G3 faxes are 204 dots per inch (dpi) horizontally and 98 dpi (196 dpi optionally, in fine-detail mode) vertically.

       The standards specify three file formats (also called coding methods and compression schemes -- remember the standard doesn't mention  com-
       puter files; it talks about the format of a stream of bits travelling over a telephone line):

       MH     This compresses in one dimension: it compresses individual raster lines but makes no attempt to compress redundancy between lines.

	      One  dimensional compression is traditionally the best a fax machine could handle because G3 neither assumes error free transmission
	      not retransmits when errors occur, and receiving fax machines traditionally could not afford to buffer much of a page.  It's  impor-
	      tant that when there is an error in a raster line, its impact not spread to many lines after it.

	      All Group 3 and Group 4 fax machines must be able to send and receive MH.

	      MH  is  sometimes  called  'G3,' but that is a poor name because while the Group 3 standard does specify MH, it has always specified
	      other formats too.

	      MH is sometimes called 'T4' based on the name of the document that specifies it, ITU T.4.  But this is a poor name because T.4  also
	      specifies MR.

       MR     This compresses in two dimensions, horizontally and vertically.

	      MR  has  always been part of the Group 3 standard, but is optional (a Group 3 fax machine may or may not be able to send and receive
	      it).

       MMR    This is a more advanced format than the others.  It is even more two-dimensional than MR.  It is optional in the Group  3  standard,
	      and  didn't  even  exist	in  earlier  versions of it.  It was developed specifically for the Group 4 standard, but then added to an
	      extended Group 3 standard as well.

	      MMR is sometimes called Group 4, but that is a poor name because of the fact that it is also part of the current Group 3 standard.

	      MMR is sometimes called 'T6' based on the name of the document
	       that specifies it, ITU T.6.

       g3topbm converts the MH format to PBM.  pbmtog3 converts PBM to MH.

       There is no Netpbm program to convert to or from other fax formats.

TIFF
The TIFF format is flexible enough to allow lots of different coding methods, within it. There are TIFF subformats for MH, MR, and MMR, among others. These are particularly useful when you receive a fax as a TIFF file. tifftopnm recognizes and can convert from any of these. pamtotiff can convert to any of these; you use command options to choose which. netpbm documentation 03 December 2008 Fax Formats(1)
All times are GMT -4. The time now is 05:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy