Sponsored Content
Top Forums Shell Programming and Scripting Calculate the total 4 field based on the conditions Post 302959346 by kalia4u on Sunday 1st of November 2015 10:17:12 AM
Old 11-01-2015
sorry for getting replay late Busy with other task
Code:
awk -F\| '
FNR==1  {comp=$1 and $2
        }
comp!=$1 && $2 {print "Total", add3, add4,add5,add6; 
        }
        {
         add3+=$3
         add4+=$4
         add5+=$5
         add6+=$6
        }
ACNO=$1 {
         gt1+=$3
         gt2+=$4
         gt3+=$5
         gt4+=$6
         }
END     {print "Total", add1,add2,add3,add4
         print "   Grand Total","   ", gt1, gt2,gt3,gt4
        }
'

Getting error not able to execute please help me out this issue

Moderator's Comments:
Mod Comment Please pay attention at the moderator's comment you got:
The CODE tags need to be positioned as:
Code:
sample input or output or code

not as:
sample input or output or code

Last edited by vbe; 11-01-2015 at 12:06 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script to calculate total

Hi First field is the Record Type. A Record Type 5 can have multiple Record Type 6's before another Record Type 5 appears. I want to calculate the total of fields at position 8-11 on Record type 6 when Record Type 5 has a field at position 11-14 equals to '2222'. then it should delete the lines... (2 Replies)
Discussion started by: appsguy616
2 Replies

2. Shell Programming and Scripting

Calculate total sum from a file

The file content is dynamic and using this format: name1 number1 name2 number2 name3 number3 name4 number4 .................... Need a smooth way to calculate the sum of all the numbers in that file (number1 + number2 + number3 + number4........ = total ) (11 Replies)
Discussion started by: TehOne
11 Replies

3. Shell Programming and Scripting

Calculate total space, total used space and total free space in filesystem names matching keyword

Good afternoon! Im new at scripting and Im trying to write a script to calculate total space, total used space and total free space in filesystem names matching a keyword (in this one we will use keyword virginia). Please dont be mean or harsh, like I said Im new and trying my best. Scripting... (4 Replies)
Discussion started by: bigben1220
4 Replies

4. Shell Programming and Scripting

Extract file records based on some field conditions

Hello Friends, I have a file(InputFile.csv) with the following columns(the columns are pipe-delimited): ColA|ColB|ColC|ColD|ColE|ColF Now for this file, I have to get those records which fulfil the following condition: If "ColB" is NOT NULL and "ColD" has values one of the following... (9 Replies)
Discussion started by: mehimadri
9 Replies

5. Shell Programming and Scripting

Adding total of first field for each number in the second field

Dears, I need a script or command which can find the unique number from the second filed and against that number it adds the total of first field . 17215630 , 0 907043 ,1 201050 ,10 394149 ,4 1964 ,9 17215630, 0 907043 ,1 201050, 10 394149 ,4 1964 ,9 1234234, 55 23 ,100 33 ,67 ... (2 Replies)
Discussion started by: shary
2 Replies

6. Shell Programming and Scripting

Calculate total value from a row

HI I have a file # cat marks.txt MARKS LIST 2013 Name english french chinese latin total_marks wer 34 45 67 23 wqa 12 39 10 56 wsy 23 90 23 78 Now i need to find the total marks of each student using... (11 Replies)
Discussion started by: Priya Amaresh
11 Replies

7. Shell Programming and Scripting

Calculate the total

Hi All , I have the following script as below , I tried to modify to meet the requirement , could someone help ? very thanks ================================================================================================ while read STR NAME; do Total=0 MyString="$STR" GetData () {... (18 Replies)
Discussion started by: ust3
18 Replies

8. Shell Programming and Scripting

awk to calculate total and percent off field in file

Trying to use awk to print the lines in file that have either REF or SNV in $3, add a header line, sort by $4 in numerical order. The below code does that already, but where I am stuck is on the last part where the total lines are counted and printed under Total_Targets, under Targets_less_than is... (4 Replies)
Discussion started by: cmccabe
4 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
NCFLINT(1)						      General Commands Manual							NCFLINT(1)

NAME
ncflint - netCDF File Interpolator SYNTAX
ncflint [-3] [-4] [-6] [-A] [-C] [-c] [-D dbg] [-d dim,[ min][,[ max]]] [-F] [-h] [-i var,val3][-L dfl_lvl][-l path] [-O] [-p path] [-R] [-r] [-t thr_nbr] [-v var[,...]] [-w wgt[, wgt2]] [-X box] [-x] file1 file2 file3 DESCRIPTION
ncflint creates an output file that is a linear combination of the input files. This linear combination can be a weighted average, a nor- malized weighted average, or an interpolation of the input files. Coordinate variables are not acted upon in any case, they are simply copied from file_1. There are two conceptually distinct methods of using ncflint. The first method is to specify the weight each input file is to have in the output file. In this method, the value val3 of a variable in the output file file_3 is determined from its values val1 and val2 in the two input files according to wgt1*val1+wgt2*val2 Here at least wgt1, and, optionally, wgt2, are specified on the command line with the -w (or --weight or --wgt_var ) switch. If only IR wgt1 is specified then wgt2 is automatically computed as wgt2=1-wgt1. Note that weights larger than 1 are allowed. Thus it is possible to specify wgt1=2 and wgt2=-3. One can use this functionality to multiply all the values in a given file by a constant. The second method of using ncflint is to specify the interpolation option with -i (or with the --ntp or --interpolate long options). This is really the inverse of the first method in the following sense. When the user specifies the weights directly, ncflint has no work to do besides multiplying the input values by their respective weights and adding the results together to produce the output values. This assumes it is the weights that are known a priori. In another class of cases it is the "arrival value" (i.e., val3 ) of a particular vari- able var that is known a priori. In this case, the implied weights can always be inferred by examining the values of var in the input files. This results in one equation in two unknowns, wgt1 and wgt2: val3=wgt1*val1+wgt2*val2. Unique determination of the weights requires imposing the additional constraint of normalization on the weights: wgt1+wgt2=1. Thus, to use the interpolation option, the user specifies var and val3 with the -i option. ncflint will compute wgt1 and wgt2, and use these weights on all variables to generate the output file. Although var may have any number of dimensions in the input files, it must represent a single, scalar value. Thus any dimensions associated with var must be "degenerate", i.e., of size one. If neither -i nor -w is specified on the command line, ncflint defaults to weighting each input file equally in the output file. This is equivalent to specifying -w0.5 or -w0.5,0.5. Attempting to specify both .BR -i and -w methods in the same command is an error. ncflint is programmed not to interpolate variables of type NC_CHAR and NC_BYTE. This behavior is hardcoded. AUTHOR
NCO manual pages written by Charlie Zender and Brian Mays. REPORTING BUGS
Report bugs to <http://sf.net/bugs/?group_id=3331>. COPYRIGHT
Copyright (C) 1995-2010 Charlie Zender This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
The full documentation for NCO is maintained as a Texinfo manual called the NCO User's Guide. Because NCO is mathematical in nature, the documentation includes TeX-intensive portions not viewable on character-based displays. Hence the only complete and authoritative versions of the NCO User's Guide are the PDF (recommended), DVI, and Postscript versions at <http://nco.sf.net/nco.pdf>, <http://nco.sf.net/nco.dvi>, and <http://nco.sf.net/nco.ps>, respectively. HTML and XML versions are available at <http://nco.sf.net/nco.html> and <http://nco.sf.net/nco.xml>, respectively. If the info and NCO programs are properly installed at your site, the command info nco should give you access to the complete manual, except for the TeX-intensive portions. HOMEPAGE
The NCO homepage at <http://nco.sf.net> contains more information. NCFLINT(1)
All times are GMT -4. The time now is 10:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy