Sponsored Content
Top Forums Shell Programming and Scripting Subtracting each row from the first row in a single column file using awk Post 302618831 by ks_reddy on Wednesday 4th of April 2012 01:29:14 PM
Old 04-04-2012
I want row1 need to be subtracted from all rows including row itself.

I need the following operation to be done.
(Row1-Row1)
(Row2-Row1)
(Row3-Row1)
...
So on..
The script "awk '$1--{print}'" is not giving correct output.
For the input of
Code:
1.1
2.5
3.2
4
5
6

I got the output as
Code:
0.1
1.5
2.2
3
4
5

which is not correct..
Can you please modify the script to match requirement.

Thanks
Sidda

Last edited by Scrutinizer; 04-04-2012 at 02:39 PM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Changing the column for a row in a text file and adding another row

Hi, I want to write a shell script which increments a particular column in a row from a text file and then adds another row below the current row with the incremented value . For Eg . if the input file has a row : abc xyz lmn 89 lm nk o p I would like the script to create something like... (9 Replies)
Discussion started by: aYankeeFan
9 Replies

2. Shell Programming and Scripting

Converting Column values to comma delimted single Row

I have a requirement in which i have to read a file which has multiple columns seperated by a pipe "|" from this i have to read each column values seperately and create a comma seperated row for the column and write to another file. eg: Input file: ColA ColB 1 2 2 x 3 y... (5 Replies)
Discussion started by: nvuradi
5 Replies

3. Shell Programming and Scripting

Concatenating column values with unique id into single row

Hi, I have a table in Db2 with data say id_1 phase1 id_1 phase2 id_1 phase3 id_2 phase1 id_2 phase2 I need to concatenate the values like id_1 phase1,phase2,phase3 id_2 phase1,phase2 I tried recursive query but in vain as the length of string to be concatenated in quite long. ... (17 Replies)
Discussion started by: jsaravana
17 Replies

4. Shell Programming and Scripting

Moving data from a specified column/row to another column/row

Hello, I have an input file like the following: 11_3_4 2_1_35 3_15__ _16989 Where '_' is a space. The data is in a table. Is there a way for the program to prompt the user for x1,y1 and x2,y2, where x1,y1 is the desired number (for example x=6 y=4 is a value of 4) and move to a desired spot... (2 Replies)
Discussion started by: jl487
2 Replies

5. Shell Programming and Scripting

duplicate row based on single column

I am a newbie to shell scripting .. I have a .csv file. It has 1000 some rows and about 7 columns... but before I insert this data to a table I have to parse it and clean it ..basing on the value of the first column..which a string of phone number type... example below.. column 1 ... (2 Replies)
Discussion started by: mitr
2 Replies

6. Shell Programming and Scripting

How to merge multiple rows into single row if first column matches ?

Hi, Can anyone suggest quick way to get desired output? Sample input file content: A 12 9 A -0.3 2.3 B 1.0 -4 C 34 1000 C -111 900 C 99 0.09 Output required: A 12 9 -0.3 2.3 B 1.0 -4 C 34 1000 -111 900 99 0.09 Thanks (3 Replies)
Discussion started by: cbm_000
3 Replies

7. UNIX for Dummies Questions & Answers

append column and row header to a file in awk script.

Hi! Is there a way to append column and row header to a file in awk script. For example if I have Jane F 39 manager Carlos M 40 system administrator Sam F 20 programmer and I want it to be # name gend age occup 1 Jane F 39 manager 2 Carlos M ... (4 Replies)
Discussion started by: FUTURE_EINSTEIN
4 Replies

8. UNIX for Dummies Questions & Answers

awk to print first row with forth column and last row with fifth column in each file

file with this content awk 'NR==1 {print $4} && NR==2 {print $5}' file The error is shown with syntax error; what can be done (4 Replies)
Discussion started by: cdfd123
4 Replies

9. Shell Programming and Scripting

Print row on 4th column to all row

Dear All, I have input : SEG901 5173 9005 5740 SEG902 5227 5284 SEG903 5284 5346 SEG904 5346 9010 SEG905 5400 5456 SEG906 5456 5511 SEG907 5511 9011 SEG908 5572 9015 SEG909 5622 9020 SEG910 5678 5739 SEG911 5739 5796 SEG912 5796 9025 ... (3 Replies)
Discussion started by: attila
3 Replies

10. Shell Programming and Scripting

Splitting single row into multiple rows based on for every 10 digits of last field of the row

Hi ALL, We have requirement in a file, i have multiple rows. Example below: Input file rows 01,1,102319,0,0,70,26,U,1,331,000000113200000011920000001212 01,1,102319,0,1,80,20,U,1,241,00000059420000006021 I need my output file should be as mentioned below. Last field should split for... (4 Replies)
Discussion started by: kotra
4 Replies
tixGrid(n)						       Tix Built-In Commands							tixGrid(n)

NAME
tixGrid - Create and manipulate Tix Grid widgets -background -borderWidth -cursor -font -foreground -height -highlight- Color -highlightThickness -relief -selectBackground -selectForeground -width -xScrollCommand -yScrollCommand WIDGET-SPECIFIC OPTIONS [-editdonecmd editDoneCmd] If non-empty, gives a Tcl command to be executed when the user has edited grid cell. When this command is called, it is passed with two additional parameters: x y, where (x,y) is the location of the cell that has just been edited. [-editnotify- cmd editNotifyCmd] If non-empty, gives a Tcl command to be executed when the user tries to edit a grid cell. When this command is called, it is passed with two additional parameters: x y, where (x,y,) is the location of the cell. This command should return a boolean value: true indicates that the cells is editable and false otherwise. [-formatcmd formatCmd] If non-empty, gives a Tcl command to be executed when the grid cells need to be formatted on the screen. Normally, this command calls the format widget command (see below). When this com- mand is called, it is passed with five additional parameters: type x1 y1 x2 y2. type gives the logical type of the region in the grid. It may be one of the following. x-region: the horizontal margin; y-region: the vertical margin; s-region, the area where the the horizontal and vertical margins are joined; main: all the cells that do not fall into the above three types. x1 y1 x2 y2 gives the extent of the region that needs formatting. [-leftmargin leftMargin] In the number of cells, gives the width of vertical margin. A zero indicates that no vertical should be drawn. [-selectmode selectMode] Specifies one of several styles for manipulating the selection. The value of the option may be arbitrary, but the default bindings expect it to be either single, browse, multiple, or extended; the default value is sin- gle. [-selectunit selectUnit] Specifies the selection unit. Valid values are cell, column or row. [-topmargin topMargin] In the number of cells, gives the height of horizontal margin. A zero indicates that no horizontal should be drawn. DESCRIPTION
The tixGrid command creates a new window (given by the pathName argument) and makes it into a tixGrid widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the tixGrid widget such as its cur- sor and relief. A Grid widget displays its contents in a two dimensional grid of cells. Each cell may contain one Tix display item, which may be in text, graphics or other formats. See the tixDisplayStyle manual page for more information about Tix display items. Individual cells, or groups of cells, can be formatted with a wide range of attributes, such as its color, relief and border. WIDGET COMMAND
The tixGrid command creates a new Tcl command whose name is the same as the path name of the tixGrid widget'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 tixGrid widget's path name. Option and the args determine the exact behavior of the command. The following commands are possible for tixGrid widgets: pathName anchor option ?args ...? Manipulates the anchor cell of the tixGrid widget. The anchor cell is the end of the selection that is fixed while the user is drag- ging out a selection with the mouse. pathName bdtype TODO place holder pathName cget option Returns the current value of the configuration option given by option. Option may have any of the values accepted by the tixGrid 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(n) 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 wid- get 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 tixGrid command. pathName delete dim from ?to? Dim may be row or column. If to is not given, deletes a single row (or column) at the position from. If to is given, deletes the range of rows (or columns) from position from through to. pathName edit apply If any cell is being edited, de-highlight the cell and applies the changes. pathName edit set x y Highlights the cell at (x,y) for editing, if the -editnotify command returns true for this cell. pathName entrycget x y option Returns the current value of the configuration option given by option of the cell at (x,y). Option may have any of the values accepted by the set widget command. pathName entryconfigure x y ?option? ?value option value ...? Query or modify the configuration options of the cell at (x,y). If no option is specified, returns a list describing all of the available options for the cell (see Tk_ConfigureInfo(n) 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 set widget command. pathName format TODO place holder pathName index TODO place holder pathName move dim from to offset Dim may be row or column. Moves the the range of rows (or columns) from position from through to by the distance indicated by off- set. For example, move row 2 4 1 moves the rows 2,3,4 to rows 3,4,5. pathName set x y ?-itemtype type? ?option value...? Creates a new display item at the cell at (x,y). The optional -itemtype parameter gives the type of the display item. An additional list of option-value pairs specify options of the display item. If a display item already exists at this cell, the old item will be deleted automatically. pathName size dim index ?option value ...? Queries or sets the size of the row or column given by dim and index. Dim may be row or column. Index may be any non-negative inte- ger that gives the position of a given row (or column). Index can also be the string default; in this case, this command queries or sets the default size of all rows (or columns). When no option-value pair is given, this command returns a list containing the current size setting of the given row (or column). When option-value pairs are given, the corresponding options of the size setting of the given row are changed. Option may be one of the foll- wing: -pad0 pixels Specifies the paddings to the left or a column or the top of a row. -pad1 pixels Specifies the paddings to the right or a column or the bottom of a row. -size val Specifies the width of a column or the height of a row. Val may be: auto -- the width of the column is set the the widest cell in the column; a valid Tk screen distance unit (see Tk_GetPixels(n)); or a real number following by the word chars (e.g. 3.4chars) that sets the width of the column to the given number of characters. pathName unset x y Clears the cell at (x,y) by removing its display item. pathName xview TODO place holder pathName yview TODO place holder KEYWORDS
grid, spread sheet, table Tix 4.1 tixGrid(n)
All times are GMT -4. The time now is 07:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy