Sponsored Content
Full Discussion: awk multidimensional values
Top Forums Shell Programming and Scripting awk multidimensional values Post 302255120 by Ygor on Wednesday 5th of November 2008 11:59:52 PM
Old 11-06-2008
Try...
Code:
NR > 1  {
    if (a[$1] == $1) {
        b[$1] = b[$1] "," $2
        c[$1] = c[$1] "," $3
        d[$1] = d[$1] "," $4
    } else {
        a[$1] = $1
        b[$1] = $2
        c[$1] = $3
        d[$1] = $4
    }
}

END {
    for (i in a) {
            printf "update/%s={[%s], COL2=[%s], COL3=[%s])\n", a[i], b[i], c[i], d[i]
    }
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk multidimensional Array

Hello Experts,, Can anybody give me a brief idea what is following bold letter statement is for!! what is the term called so that I can google for it.. It seems to be an array inside another array.. awk' /TXADDR/ { txaddr=$NF } ##understood /TXDATA/ { txdata]=$NF... (1 Reply)
Discussion started by: user_prady
1 Replies

2. Shell Programming and Scripting

AWK multidimensional array

In a single dim. awk array, we can use : <index> in <array name> to determine whether a particualar index exists in the array or not. Is there a way to achieve this in a awk multi dim. array ? (4 Replies)
Discussion started by: sinpeak
4 Replies

3. Shell Programming and Scripting

How to pick values from column based on key values by usin AWK

Dear Guyz:) I have 2 different input files like this. I would like to pick the values or letters from the inputfile2 based on inputfile1 keys (A,F,N,X,Z). I have done similar task by using awk but in that case the inputfiles are similar like in inputfile2 (all keys in 1st column and values in... (16 Replies)
Discussion started by: repinementer
16 Replies

4. Shell Programming and Scripting

multidimensional arrays using awk

i'm trying to use awk to count a listing similar to the following and get a report of the listing similar to the one below it. y,pizza n,pizza y,pizza y,pizza n,tomato n,tomato y,cheese y,cheese n,cheese report ---- pizza,3,1 tomato,0,2 cheese,2,1 (1 Reply)
Discussion started by: multimulti
1 Replies

5. Shell Programming and Scripting

AWK: read values from file1; search for values in file2

I have read another post about this issue and am wondering how to adapt it to my own, much simpler, issue. I have a file of user IDs like so: 333333 321321 546465 ...etc I need to take each number and use it to print records wherein the 5th field matches the user ID pulled from the... (2 Replies)
Discussion started by: Bubnoff
2 Replies

6. Shell Programming and Scripting

multidimensional array in awk

Hi, I was trying to process a file with the help of awk. I want to first display all the rows that contains 01 and at the end of processing I have to print some portion of all the lines. like below. Output expected: (2 Replies)
Discussion started by: ahmedwaseem2000
2 Replies

7. Shell Programming and Scripting

How to deal with multidimensional array in awk?

Hi all! I would like to know how to print $0 when using multidimensional array like below time being I am using for loop to print columns like this awk 'FNR==1{i++} {for(k=1;k<=NF;k++)A=$k} END{for(j=1;j<=25;j++) print A,A,A,A,A,A,A,A,A,A,A,A,A,A}' file1 file2 so here my problem is I... (5 Replies)
Discussion started by: Akshay Hegde
5 Replies

8. Shell Programming and Scripting

How to find the X highest values in a list depending on the values of another list with bash/awk?

Hi everyone, This is an exemple of inpout.txt file (a "," delimited text file which can be open as csv file): ID, Code, Value, Store SP|01, AABBCDE, 15, 3 SP|01, AABBCDE, 14, 2 SP|01, AABBCDF, 13, 2 SP|01, AABBCDE, 16, 3 SP|02, AABBCED, 15, 2 SP|01, AABBCDF, 12, 3 SP|01, AABBCDD,... (1 Reply)
Discussion started by: jeremy589
1 Replies

9. Shell Programming and Scripting

awk file to read values from Db2 table replacing hard coded values

Hi, I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below... if (start_new_rec=="true"){ exclude_user="false"; user=toupper($6); match(user, "XXXXX."); if (RSTART ==2 ) { ... (9 Replies)
Discussion started by: asandy1234
9 Replies

10. Shell Programming and Scripting

Multidimensional array:awk error

awk -F'\t' -v OFS='\t' ' { if($2 in arr) { #print "Sahi", NR,arr for(k=2;k<=NF;k++){ # sum]+=$2 } } else { arr=NR #print "awk",NR for (k=3;k<=NF ; k++){ sum=$k } } } (7 Replies)
Discussion started by: genome
7 Replies
END(3)							     Linux Programmer's Manual							    END(3)

NAME
etext, edata, end - end of program segments SYNOPSIS
extern etext; extern edata; extern end; DESCRIPTION
The addresses of these symbols indicate the end of various program segments: etext This is the first address past the end of the text segment (the program code). edata This is the first address past the end of the initialized data segment. end This is the first address past the end of the uninitialized data segment (also known as the BSS segment). CONFORMING TO
Although these symbols have long been provided on most Unix systems, they are not standardized; use with caution. NOTES
The program must explicitly declare these symbols; they are not defined in any header file. On some systems the names of these symbols are preceded by underscores, thus: _etext, _edata, and _end. These symbols are also defined for programs compiled on Linux. At the start of program execution, the program break will be somewhere near &end (perhaps at the start of the following page). However, the break will change as memory is allocated via brk(2) or malloc(3). Use sbrk(2) with an argument of zero to find the current value of the program break. EXAMPLE
When run, the program below produces output such as the following: $ ./a.out First address past: program text (etext) 0x8048568 initialized data (edata) 0x804a01c uninitialized data (end) 0x804a024 Program source #include <stdio.h> #include <stdlib.h> extern char etext, edata, end; /* The symbols must have some type, or "gcc -Wall" complains */ int main(int argc, char *argv[]) { printf("First address past: "); printf(" program text (etext) %10p ", &etext); printf(" initialized data (edata) %10p ", &edata); printf(" uninitialized data (end) %10p ", &end); exit(EXIT_SUCCESS); } SEE ALSO
objdump(1), readelf(1), sbrk(2), elf(5) COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2008-07-17 END(3)
All times are GMT -4. The time now is 04:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy