Sponsored Content
Top Forums Shell Programming and Scripting Breaking the sum of a column when specific pattern is found Post 302809583 by Priya Amaresh on Monday 20th of May 2013 07:46:48 AM
Old 05-20-2013
I tried the following code
Code:
# awk '{print $2}' /out | grep '[0-9]' | awk '{RS="----"} {sum+=$1} END {print sum}'
2094

This prints the last sum value between "---------" and "-------------" i need to print all sum values between "---------" and "-------------"

For eg.,
first SUM 10
second SUM 20
like wise between "---------" and "-------------" i need the total value
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Breaking output for specific pattern

Respected Sirs, I have a text file which is unfortunately unformatted. I have something like 191728/02/06226278 191828/02/06226279 191928/02/06226280 192028/02/06226281 192128/02/06226282 Can some one suggest me the way so that I can store 1917 28/02/06 226278 in different... (2 Replies)
Discussion started by: shoeb_syed
2 Replies

2. Shell Programming and Scripting

Print rows, having pattern in specific column...

Hello all, :) I have a pattern file some what like this, cd003 cd005 cd007 cd008 and input file like this, abc cd001 cd002 zca bca cd002 cd003 cza cba cd003 cd004 zca bac cd004 cd005 zac cba cd005 cd006 acz acb cd006 cd007 caz cab cd007 ... (25 Replies)
Discussion started by: admax
25 Replies

3. Shell Programming and Scripting

Print out specific pattern column data

Input file: adc_0123 haa_1000 bcc_520 adc_0150 bcc_290 adc_0112 haa_8000 adc_0139 haa_7000 Output file: adc_0123 adc_0123 haa_1000 bcc_520 adc_0150 adc_0150 bcc_290 (3 Replies)
Discussion started by: patrick87
3 Replies

4. Shell Programming and Scripting

extract specific line if the search pattern is found

Hi, I need to extract <APPNUMBER> tag alone, if the <college> haas IIT Chennai value. college tag value will have spaces embedded. Those spaces should not be suppresses. My Source file <Record><sno>1</sno><empid>E0001</empid><name>Rejsh suderam</name><college>IIT ... (3 Replies)
Discussion started by: Sekar1
3 Replies

5. Shell Programming and Scripting

awk to sum specific field when pattern matches

Trying to sum field #6 when field #2 matches string as follows: Input data: 2010-09-18-20.24.44.206117 UOWEXEC db2bp DB2XYZ hostname 1 2010-09-18-20.24.44.206117 UOWWAIT db2bp DB2XYZ hostname ... (3 Replies)
Discussion started by: ux4me
3 Replies

6. Shell Programming and Scripting

Replace column that matches specific pattern, with column data from another file

Can anyone please help with this? I have 2 files as given below. If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value. file1 abc_1 foo1@a .... abc_1 soo2@a ... def_2 soo2@a .... def_2 foo1@a ........ (7 Replies)
Discussion started by: prashali
7 Replies

7. Shell Programming and Scripting

Sum of column matching pattern/string

Hi All, I have the following output file created as a result of one script called pattern_daily.log $ cat pattern_daily.log Approved|2|Wed, Oct 24, 2012 11:21:09 AM Declined|1|Wed, Oct 24, 2012 11:21:15 AM Approved|2|Wed, Oct 24, 2012 11:24:08 AM Declined|1|Wed, Oct 24, 2012 11:24:18 AM... (4 Replies)
Discussion started by: Gem_In_I
4 Replies

8. Shell Programming and Scripting

To add a new line with specific text after the pattern is found using sed

hi guys, im trying to add the following line in my xml file <dbrollbacksegs <oa_var="s_db_rollback_segs">NOROLLBACK</dbrollbacksegs> when ever i find the following line <dbsharedpool oa_var="s_dbsharedpool_size">300000000</dbsharedpool> I have succedded till adding a new line... (1 Reply)
Discussion started by: smarlaku
1 Replies

9. Shell Programming and Scripting

If first pattern is found, look for second pattern. If second pattern not found, delete line

I had a spot of trouble coming up with a title, hopefully you'll understand once you read my problem... :) I have the output of an ldapsearch that looks like this: dn: cn=sam,ou=company,o=com uidNumber: 7174 gidNumber: 49563 homeDirectory: /home/sam loginshell: /bin/bash uid: sam... (2 Replies)
Discussion started by: samgoober
2 Replies

10. Shell Programming and Scripting

Sum values of specific column in multiple files, considering ranges defined in another file

I have a file (let say file B) like this: File B: A1 3 5 A1 7 9 A2 2 5 A3 1 3 The first column defines a filename and the other two define a range in that specific file. In the same directory, I have also three more files (File A1, A2 and A3). Here is 10 sample lines... (3 Replies)
Discussion started by: Bastami
3 Replies
mlib_VectorSumAbs_U8_Sat(3MLIB) 			    mediaLib Library Functions				   mlib_VectorSumAbs_U8_Sat(3MLIB)

NAME
mlib_VectorSumAbs_U8_Sat, mlib_VectorSumAbs_S8_Sat, mlib_VectorSumAbs_S16_Sat, mlib_VectorSumAbs_S32_Sat - sum of the absolute values of a vector SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ] #include <mlib.h> mlib_status mlib_VectorSumAbs_U8_Sat(mlib_d64 *z, const mlib_u8 *x, mlib_s32 n); mlib_status mlib_VectorSumAbs_S8_Sat(mlib_d64 *z, const mlib_s8 *x, mlib_s32 n); mlib_status mlib_VectorSumAbs_S16_Sat(mlib_d64 *z, const mlib_s16 *x, mlib_s32 n); mlib_status mlib_VectorSumAbs_S32_Sat(mlib_d64 *z, const mlib_s32 *x, mlib_s32 n); DESCRIPTION
Each of these functions computes the sum of the absolute values of a vector. The following equation is used: n-1 z[0] = SUM |x[i]| i=0 PARAMETERS
Each of the functions takes the following arguments: z Pointer to the sum of the absolute values of the vector. x Pointer to the first element of the first source vector. n Number of elements in the vectors. RETURN VALUES
Each of the functions returns MLIB_SUCCESS if successful. Otherwise it returns MLIB_FAILURE. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) SunOS 5.10 10 Nov 2004 mlib_VectorSumAbs_U8_Sat(3MLIB)
All times are GMT -4. The time now is 04:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy