Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to sum a column 2 and column 3 Post 302599367 by Paulwintech on Friday 17th of February 2012 01:01:11 AM
Old 02-17-2012
Thank you!!! mistake is in my side sorry!!! command which you gave works fine..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I sum one column based on another column?

Hi, I am new to this forum and new to awk. I have a file that contains 2 columns. Heres an example of what it looks like: 10 + 20 + 40 + 50 - 70 - So the file is tab-delimited. What I want to do is add 10 to column 1 whenever column 2 is + and substract 10 from column 1... (1 Reply)
Discussion started by: phil_heath
1 Replies

2. Shell Programming and Scripting

print unique values of a column and sum up the corresponding values in next column

Hi All, I have a file which is having 3 columns as (string string integer) a b 1 x y 2 p k 5 y y 4 ..... ..... Question: I want get the unique value of column 2 in a sorted way(on column 2) and the sum of the 3rd column of the corresponding rows. e.g the above file should return the... (6 Replies)
Discussion started by: amigarus
6 Replies

3. UNIX for Dummies Questions & Answers

How to sum rows in e.g. column 1 by a category in e.g. column 2

Hi, I've shown an example of what I would like to achieve below. In the example file, I would like to sum the values in column 2 for each distinct category in column 3 (presumably making an array?) and print the sum as well as the category name and length (note:length always corresponds with... (8 Replies)
Discussion started by: auburn
8 Replies

4. Shell Programming and Scripting

Sum Of Column Based On Column Condition

I have a following inputfile MT,AP,CDM,TTML,MUM,GS,SUCC,3 MT,AP,CDM,TTSL,AP,GS,FAIL,9 MT,AP,CDM,RCom,MAH,GS,SUCC,3 MT,AP,CDM,RTL,HP,GS,SUCC,1 MT,AP,CDM,Uni,UPE,GS,SUCC,2 MT,AP,CDM,Uni,MUM,GS,SUCC,2 TTSL,AP,GS,MT,MAH,CDM,SUCC,20 TTML,AP,GS,MT,MAH,CDM,FAIL,10... (2 Replies)
Discussion started by: siramitsharma
2 Replies

5. Shell Programming and Scripting

awk to sum a column based on duplicate strings in another column and show split totals

Hi, I have a similar input format- A_1 2 B_0 4 A_1 1 B_2 5 A_4 1 and looking to print in this output format with headers. can you suggest in awk?awk because i am doing some pattern matching from parent file to print column 1 of my input using awk already.Thanks! letter number_of_letters... (5 Replies)
Discussion started by: prashob123
5 Replies

6. Shell Programming and Scripting

Sum column values based in common identifier in 1st column.

Hi, I have a table to be imported for R as matrix or data.frame but I first need to edit it because I've got several lines with the same identifier (1st column), so I want to sum the each column (2nd -nth) of each identifier (1st column) The input is for example, after sorted: K00001 1 1 4 3... (8 Replies)
Discussion started by: sargotrons
8 Replies

7. UNIX for Dummies Questions & Answers

Match sum of values in each column with the corresponding column value present in trailer record

Hi All, I have a requirement where I need to find sum of values from column D through O present in a CSV file and check whether the sum of each Individual column matches with the value present for that corresponding column present in the trailer record. For example, let's assume for column D... (9 Replies)
Discussion started by: tpk
9 Replies

8. UNIX for Beginners Questions & Answers

Sum the values in the column using date column

I have a file which need to be summed up using date column. I/P: 2017/01/01 a 10 2017/01/01 b 20 2017/01/01 c 40 2017/01/01 a 60 2017/01/01 b 50 2017/01/01 c 40 2017/01/01 a 20 2017/01/01 b 30 2017/01/01 c 40 2017/02/01 a 10 2017/02/01 b 20 2017/02/01 c 30 2017/02/01 a 10... (6 Replies)
Discussion started by: Booo
6 Replies

9. Shell Programming and Scripting

awk to Sum columns when other column has duplicates and append one column value to another with Care

Hi Experts, Please bear with me, i need help I am learning AWk and stuck up in one issue. First point : I want to sum up column value for column 7, 9, 11,13 and column15 if rows in column 5 are duplicates.No action to be taken for rows where value in column 5 is unique. Second point : For... (1 Reply)
Discussion started by: as7951
1 Replies

10. Shell Programming and Scripting

Sum of a column as new column based on header in a script

Hello, I am trying to store sum of a column as a new column inside a file but have to find the column names dynamically I/p c1,c2,c3,c4,c5 10,20,30,40,50 20,30,40,50,60 If i want to find sum only column c1, c3 and output it as c6,c7 O/p c1,c2,c3,c4,c5,c6,c7 10,20,30,40,50,30,70... (6 Replies)
Discussion started by: mkathi
6 Replies
Adjuster(3)						User Contributed Perl Documentation					       Adjuster(3)

NAME
Tk::Adjuster - Allow size of packed widgets to be adjusted by user SYNOPSIS
use Tk::Adjuster; $adjuster = $widget->Adjuster(?options?); WIDGET-SPECIFIC OPTIONS Name: restore Class: Restore Switch: -restore Specifies a boolean value that determines whether the Adjuster should forcibly attempt to make room for itself (by reducing the size of its managed widget) when it is unmapped (for example, due to a size change in a top level window). The default value is 1. Name: side Class: Side Switch: -side Specifies the side on which the managed widget lies relative to the Adjuster. In conjunction with the pack geometry manager, this relates to the side of the master against which the managed widget and the Adjuster are packed. Must be left, right, top, or bottom. Defaults to top. Name: widget Class: Widget Switch: -widget Specifies the widget which is to be managed by the Adjuster. DESCRIPTION
Tk::Adjuster is a Frame containing a "line" and a "blob". Dragging with Mouse Button-1 results in a line being dragged to indicate new size. Releasing Button-1 submits GeometryRequests on behalf of the managed widget which will cause the packer to change the widget's size. If Drag is done with Shift button down, then GeometryRequests are made in "real time" so that text-flow effects can be seen, but as a lot more work is done behaviour may be sluggish. If widget is packed with -side => left or -side => right then width is adjusted. If packed -side => top or -side => bottom then height is adjusted. packPropagate is turned off for the master window to prevent adjustment changing overall window size. Similarly packPropagate is turned off for the managed widget if it has things packed inside it. This is so that the GeometryRequests made by Tk::Adjuster are not overridden by pack. In addition, the managed widget is made non-expandable to prevent the geometry manager reallocating freed space in the master back to the managed widget. Note however that expansion is turned off only after the Adjuster is mapped, which allows the managed widget to expand naturally on window creation. The Tk::Widget method, packAdjust, calls pack on the widget, then creates an instance of Tk::Adjuster, and packs that "after" the widget. Its use has two disadvantages however: the Adjuster widget is not made available to the caller, and options cannot be set on the Adjuster. For these reasons, the Tk::Adjuster method, packAfter is preferred, but packAdjust is retained for backwards compatibility. WIDGET METHODS
$adjuster->packAfter(managed_widget, ?pack_options?) This command configures the Adjuster's -widget and -side options respectively to managed_widget and the -side value specified in pack_options (top if not specified). It then packs the Adjuster after managed_widget, with -fill set to x or y as appropriate. $adjuster->packForget?(boolean)? This command calls Tk::Widget::packForget on the Adjuster. If a parameter is provided and it has a true boolean value, then packForget is also called on the managed widget. $adjuster->slave This command returns the value $adjuster->cget('-widget'), ie. the reference to the managed widget. EXAMPLES
Using an Adjuster to separate two widgets, whereby the left widget is managed, and right widget expands to fill space on a window resize a) Using packAfter (preferred interface) use Tk; use Tk::Adjuster; my $f = MainWindow->new; my $lst1 = $f->Listbox(); my $adj1 = $f->Adjuster(); my $lst2 = $f->Listbox(); my $side = 'left'; $lst1->pack(-side => $side, -fill => 'both', -expand => 1); $adj1->packAfter($lst1, -side => $side); $lst2->pack(-side => $side, -fill => 'both', -expand => 1); MainLoop; b) Using packAdjust use Tk; use Tk::Adjuster; my $f = MainWindow->new; my $lst1 = $f->Listbox(); my $lst2 = $f->Listbox(); my $side = 'left'; $lst1->packAdjust(-side => $side, -fill => 'both'); $lst2->pack (-side => $side, -fill => 'both', -expand => 1); MainLoop; c) Using the standard Tk::Widget::pack use Tk; use Tk::Adjuster; my $f = MainWindow->new; my $side = 'left'; my $lst1 = $f->Listbox(); my $adj = $f->Adjuster(-widget => $lst1, -side => $side); my $lst2 = $f->Listbox(); $lst1->pack(-side => $side, -fill => 'both', -expand => 1); $adj->pack (-side => $side, -fill => 'y'); $lst2->pack(-side => $side, -fill => 'both', -expand => 1); MainLoop; Changing the above examples so that $side has the value 'right' means the left widget expands to fill space on a window resize. Changing the above examples so that $side has the value 'top' produces a testcase with a horizontal Adjuster. Here the bottom widget expands to fill space on a window resize. Packing to the 'bottom' makes the top widget expand to fill space on window resize. Using -restore => 0 for multiple columns In the case of multiple columns (or rows) the "restore" functionality of the Adjuster can be inconvenient. When the user adjusts the width of one column and thereby pushes the Adjuster of another column off the window, this adjuster tries to restore itself by reducing the size of its managed widget. This has the effect that column widths shrink; and the original size is not restored when the user reverses the originating change. The -restore option can be used to turn off this functionality. (It makes some sense, however, to leave -restore turned on for the first-packed Adjuster, so that at least one Adjuster always remains visible.) use Tk; use Tk::Adjuster; my $f = MainWindow->new; my $lst1 = $f->Listbox(); my $adj1 = $f->Adjuster(); my $lst2 = $f->Listbox(); my $adj2 = $f->Adjuster(-restore => 0); my $lst3 = $f->Listbox(); my $side = 'left'; $lst1->pack(-side => $side, -fill => 'both', -expand => 1); $adj1->packAfter($lst1, -side => $side); $lst2->pack(-side => $side, -fill => 'both', -expand => 1); $adj2->packAfter($lst2, -side => $side); $lst3->pack(-side => $side, -fill => 'both', -expand => 1); MainLoop; BUGS
It is currently not possible to configure the appearance of the Adjuster. It would be nice to be able to set the width and relief of the Adjuster "line" and the presence/absence of the "blob" on the Adjuster. Tk::Adjuster works theoretically with the grid geometry manager but there are currently some problems which seem to be due to bugs in grid: a) There's never an Unmap event for the adjuster, so the "restore" functionality has no effect. b) After adjusting, widgets protrude into the border of the master. c) grid('Propagate', 0) on MainWindow has no effect - window shrinks/grows when widgets are adjusted. d) Widgets shuffle to correct position on startup perl v5.16.3 2014-06-10 Adjuster(3)
All times are GMT -4. The time now is 05:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy