Visit Our UNIX and Linux User Community

Top Forums Shell Programming and Scripting multidimensional arrays using awk Post 302368401 by multimulti on Wednesday 4th of November 2009 08:05:15 PM
Old 11-04-2009
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


I know how to do a count of the number of yes's and no's individually, but not together

can anyone help me with this? i'm trying to find examples of people using multidimensional arrays with awk, but haven't found any.

thanks in advance.

-j
 
Test Your Knowledge in Computers #914
Difficulty: Medium
In bash, grep -v -e '^[[:space:]]*$' file.txt will filter all the blank lines from file.txt and save the results in a file called file.txt.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

multidimensional arrays

I have a file that's logically in the form of a multidimensional array with an unknown number of records in the file. The file looks like this: name1 data1 name2 data2 name3 data3 ... nameN dataN How do I load this file into an array for processing, while... (2 Replies)
Discussion started by: leslie02
2 Replies

2. 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

3. Shell Programming and Scripting

awk multidimensional values

Hello All, Here is my input file content and i am trying to write an awk file that produces the output as shown below. i tried with my little knowledge but was not successful. Input File content: ID COL1 COL2 COL3 1002 1 val21 val31 1002 2 val22 val32 1002 3 val23 val33... (2 Replies)
Discussion started by: forumthreads
2 Replies

4. 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

5. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 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. Programming

Multidimensional arrays and sort.

My language is C++. I have a multidimensional vector that I would like to sort by a specific "cell" or "field" within the main vector. Does anyone have any information on how to do this? I have searched all over the internet and every reference manual I can find. So far I have found very little to... (2 Replies)
Discussion started by: sepoto
2 Replies

8. Shell Programming and Scripting

Multidimensional arrays

Hi Experts, I'm a newbie.....multidimensional arrays in shell scripts is possible??? If so, can anyone guide me with an example.....and also can anyone tell me, how we can create a table like ouput format in shell script....the output should look like this one: 1 2 3 4 5 6 6 5 4 3... (4 Replies)
Discussion started by: kritibalu
4 Replies

9. Shell Programming and Scripting

Multidimensional arrays Shell Programming and Scripting

I have two files: file-1 is a list of number of interfaces in the switch and file-2 have VLAN-ID , VLAN-NAME , Interface belong to that VLAN like this: file-1: 1/1 1/2 1/3 1/4 1/5 . . file-2: 1,"vlan-wifi",1/1,1/7,1/8 (9 Replies)
Discussion started by: SULTAN01
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
labelframe(n)						       Tk Built-In Commands						     labelframe(n)

__________________________________________________________________________________________________________________________________________________

NAME
labelframe - Create and manipulate labelframe widgets SYNOPSIS
labelframe pathName ?options? STANDARD OPTIONS
-borderwidth -highlightbackground -pady -cursor -highlightcolor -relief -font -highlightthickness -takefocus -foreground -padx -text See the options manual entry for details on the standard options. WIDGET-SPECIFIC OPTIONS [-background background] This option is the same as the standard background option except that its value may also be specified as an empty string. In this case, the widget will display no background or border, and no colors will be consumed from its colormap for its background and border. [-class class] Specifies a class for the window. This class will be used when querying the option database for the window's other options, and it will also be used later for other purposes such as bindings. The class option may not be changed with the configure widget command. [-colormap colormap] Specifies a colormap to use for the window. The value may be either new, in which case a new col- ormap is created for the window and its children, or the name of another window (which must be on the same screen and have the same visual as pathName), in which case the new window will use the colormap from the specified window. If the colormap option is not specified, the new window uses the same colormap as its parent. This option may not be changed with the configure widget command. [-container container] The value must be a boolean. If true, it means that this window will be used as a container in which some other application will be embed- ded (for example, a Tk toplevel can be embedded using the -use option). The window will support the appropriate window manager protocols for things like geometry requests. The window should not have any children of its own in this application. This option may not be changed with the configure widget command. [-height height] Specifies the desired height for the window in any of the forms acceptable to Tk_Get- Pixels. If this option is less than or equal to zero then the window will not request any size at all. [-labelanchor labelAnchor] Speci- fies where to place the label. A label is only displayed if the -text option is not the empty string. Valid values for this option are (listing them clockwise) nw, n, ne, en, e, es, se, s,sw, ws, w and wn. The default value is nw. [-labelwidget labelWidget] Specifies a widget to use as label. This overrides any -text option. The widget must exist before being used as -labelwidget and if it is not a descen- dant of this window, it will be raised above it in the stacking order. [-visual visual] Specifies visual information for the new window in any of the forms accepted by Tk_GetVisual. If this option is not specified, the new window will use the same visual as its parent. The visual option may not be modified with the configure widget command. [-width width] Specifies the desired width for the window in any of the forms acceptable to Tk_GetPixels. If this option is less than or equal to zero then the window will not request any size at all. _________________________________________________________________ DESCRIPTION
The labelframe command creates a new window (given by the pathName argument) and makes it into a labelframe widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the labelframe such as its back- ground color and relief. The labelframe command returns the path name of the new window. A labelframe is a simple widget. Its primary purpose is to act as a spacer or container for complex window layouts. It has the features of a frame plus the ability to display a label. WIDGET COMMAND
The labelframe command creates a new Tcl command whose name is the same as the path name of the labelframe's window. This command may be used to invoke various operations on the widget. It has the following general form: pathName option ?arg arg ...? PathName is the name of the command, which is the same as the labelframe widget's path name. Option and the args determine the exact behavior of the command. The following commands are possible for frame widgets: pathName cget option Returns the current value of the configuration option given by option. Option may have any of the values accepted by the labelframe command. pathName configure ?option? ?value option value ...? Query or modify the configuration options of the widget. If no option is specified, returns a list describing all of the available options for pathName (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. Option may have any of the values accepted by the labelframe command. BINDINGS
When a new labelframe is created, it has no default event bindings: labelframes are not intended to be interactive. EXAMPLE
This shows how to build part of a GUI for a hamburger vendor. The labelframe widgets are used to organize the available choices by the kinds of things that the choices are being made over. grid [labelframe .burger -text "Burger"] [labelframe .bun -text "Bun"] -sticky news grid [labelframe .cheese -text "Cheese Option"] [labelframe .pickle -text "Pickle Option"] -sticky news foreach {type name val} { burger Beef beef burger Lamb lamb burger Vegetarian beans bun Plain white bun Sesame seeds bun Wholemeal brown cheese None none cheese Cheddar cheddar cheese Edam edam cheese Brie brie cheese Gruyu00e8re gruyere cheese "Monterey Jack" jack pickle None none pickle Gherkins gherkins pickle Onions onion pickle Chili chili } { set w [radiobutton .$type.$val -text $name -anchor w -variable $type -value $val] pack $w -side top -fill x } set burger beef set bun white set cheese none set pickle none SEE ALSO
frame(n), label(n), ttk::labelframe(n) KEYWORDS
labelframe, widget Tk 8.4 labelframe(n)

Featured Tech Videos

All times are GMT -4. The time now is 05:18 AM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy