Sponsored Content
Top Forums Shell Programming and Scripting awk assign output of array to specific field-number Post 302636585 by Corona688 on Monday 7th of May 2012 04:22:32 PM
Old 05-07-2012
Code:
$ cat fmrg.awk

!F { F=FILENAME; FILENUM=1 }
F != FILENAME { FILENUM++; F=FILENAME }

{
        if((!MIN) ||(MIN>$1)) MIN=$1
        if((!MAX) ||(MAX<$1)) MAX=$1
        R[$1]++; A[$1,FILENUM]=$2
}

END {
        for(X=MIN; X<=MAX; X++)
        {
                printf("%s", X);
                for(N=1; N<=FILENUM; N++)       printf("\t%s", A[X, N]);
                printf("\n");
        }
}

$ $ awk -f fmrg.awk input_6.csv input_5.csv
1       90
2
3       58
4       135     135
5               185
6               85
7       60
8       55
9
10      63
11              30

$


Last edited by Corona688; 05-07-2012 at 05:30 PM..
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

assign awk array with printf

I am trying to assign a awk array for further processing later in the script. I can't seem to figure it out. If someone could look at this and help me, I would very much appreciate it. Thanks in Advance. for ( x = 1 ; x <= Var ; x++ ) { if ( x in varr ) { ... (2 Replies)
Discussion started by: timj123
2 Replies

2. Shell Programming and Scripting

Assign dscl output to variable as an array

Greetings folks, I am trying to assign the output of a dscl command (contains name<spaces>id) to a variable as an array. Currently I am piping the output into a tmp file, then reading the tmp file into an array, then parsing the array. I would like to bypass creating the tmp file portion of... (6 Replies)
Discussion started by: macnetdaemon
6 Replies

3. Shell Programming and Scripting

Assign zero to strings that don't appear in block, store result in AWK array

Hi to all, I have this input: <group> <x "2">Group D</x> <x "3">Group B</x> <x "1">Group A</x> </group> <group> <x "1">Group E</x> <x "0">Group B</x> <x "1">Group C</x> </group> <group> ... (11 Replies)
Discussion started by: Ophiuchus
11 Replies

4. Shell Programming and Scripting

Replace specific field on specific line sed or awk

I'm trying to update a text file via sed/awk, after a lot of searching I still can't find a code snippet that I can get to work. Brief overview: I have user input a line to a variable, I then find a specific value in this line 10th field in this case. After asking for new input and doing some... (14 Replies)
Discussion started by: crownedzero
14 Replies

5. Shell Programming and Scripting

How to print with awk specific field different from specific character?

Hello, i need help with awk. I have this file: cat number DirB port 67 er_enc_out 0 er_bad_os 0 DirB port 71 er_enc_out 56 er_bad_os 0 DirB port 74 er_enc_out 0 er_bad_os 0 DirB port 75 ... (4 Replies)
Discussion started by: elilmal
4 Replies

6. Shell Programming and Scripting

How to Assign an shell array to awk array?

Hello All, Can you please help me with the below. #!/bin/bash ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5 EXTRACT_DT:30-SEP-12 VER_NUM:1" ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5... (14 Replies)
Discussion started by: Ariean
14 Replies

7. Shell Programming and Scripting

awk to find number in a field then print the line and the number

Hi I want to use awk to match where field 3 contains a number within string - then print the line and just the number as a new field. The source file is pipe delimited and looks something like 1|net|ABC Letr1|1530||| 1|net|EXP_1040 ABC|1121||| 1|net|EXP_TG1224|1122||| 1|net|R_North|1123|||... (5 Replies)
Discussion started by: Mudshark
5 Replies

8. Shell Programming and Scripting

Reverse specific field number

Hello everybody :) I have specific problem when i use rev | uniq -f 3 -c | revORIGINAL Output- (without rev | uniq -f 3 -c | rev) tibenska13 Oct 30 00:26firsth revOUTPUT- 62:00 03 tcO 31aksnebitafter uniq -f 3 -cOUTPUT- 19 62:00 03 tcO 31aksnebitafter next revOUTPUT- tibenska13 Oct 30 00:26... (7 Replies)
Discussion started by: netsys
7 Replies

9. Shell Programming and Scripting

awk to assign points to variables based on conditions and update specific field

I have been reading old posts and trying to come up with a solution for the below: Use a tab-delimited input file to assign point to variables that are used to update a specific field, Rank. I really couldn't find too much in the way of assigning points to variable, but made an attempt at an awk... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. Shell Programming and Scripting

awk to create separate files but not include specific field in output

I am trying to use awk to create (in this example) 3 seperate text file from the unique id in $1 in file, if it starts with the pattern aa. The contents of each row is used to populate each text file except for $1 which is not needed. It seems I am close but not quite get there. Thank you :). ... (3 Replies)
Discussion started by: cmccabe
3 Replies
g-ir-compiler(1)					      General Commands Manual						  g-ir-compiler(1)

NAME
g-ir-compiler - typelib compiler. SYNOPSIS
g-ir-compiler [OPTION...] GIRFILE DESCRIPTION
g-ir-compiler converts one or more GIR files into one or more typelib. It can either emit the raw typelib blob (default behavior) or C code (--code). The output will be written to standard output unless the --output is specified. OPTIONS
---help Show help options ---code Emit C code which is suitable for including in a shared library instead of a raw typelib. ---output=FILENAME Save the resulting output in FILENAME. ---verbose Show verbose messages ---debug Show debug messages ---no-init Do not include an initialization snippet to register the typelib in the respository. This can only be used if --code is also speci- fied. ---includedir=DIRECTORY Adds a directory which will be used to find includes inside the GIR format. ---module=MODULE FIXME ---shared-library=FILENAME Specifies the shared library where the symbols in the typelib can be found. The name of the library should not contain the leading lib prefix nor the ending shared library suffix. BUGS Report bugs at http://bugzilla.gnome.org/ in the glib product and introspection component. HOMEPAGE and CONTACT http://live.gnome.org/GObjectIntrospection AUTHORS
Mattias Clasen g-ir-compiler(1)
All times are GMT -4. The time now is 09:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy