Sponsored Content
Top Forums Shell Programming and Scripting Sum specified values (columns) per row Post 302898124 by pathunkathunk on Friday 18th of April 2014 08:35:29 PM
Old 04-18-2014
Thank you, this works. Would you mind also showing how I would do it if I did not want to exclude the fifth value? So just print lines where the sum of ALL values in each of columns 4-8 is at least 8? I can't tell which part of the code addresses this part of it.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sum of values coming in a row

Hi, my requirement is to sum values in a row. eg: input is: sum,value1,value2,value3,.....,value N Required Output: sum,<summation of N values> Please help me... (5 Replies)
Discussion started by: MrGopal666
5 Replies

2. Shell Programming and Scripting

Sum up values of columns in 4 files using shell script

I am new to shell script.I have records like below in 4 different files which have about 10000 records each, all records unique and sorted based on column 2. 1 2 3 4 5 6 --------------------------- SR|1010478|000044590|1|0|0| SR|1014759|000105790|1|0|0| SR|1016609|000108901|1|0|0|... (2 Replies)
Discussion started by: reach.sree@gmai
2 Replies

3. UNIX for Dummies Questions & Answers

Select 2 columns and transpose row by row

Hi, I have a tab-delimited file as follows: 1 1 2 2 3 3 4 4 a a b b c c d d 5 5 6 6 7 7 8 8 e e f f g g h h 9 9 10 10 11 11 12 12 i i j j k k l l 13 13 14 14 15 15 16 16 m m n n o o p p The output I need is: 1 1 a a 5 5 e e 9 9 i i 13... (5 Replies)
Discussion started by: mvaishnav
5 Replies

4. Shell Programming and Scripting

Evaluate 2 columns, add sum IF two columns match on two rows

Hi all, I know this sounds suspiciously like a homework course; but, it is not. My goal is to take a file, and match my "ID" column to the "Date" column, if those conditions are true, add the total number of minutes worked and place it in this file, while not printing the original rows that I... (6 Replies)
Discussion started by: mtucker6784
6 Replies

5. UNIX for Dummies Questions & Answers

Unique values in a row sum the next column in UNIX

Hi would like to ask you guys any advise regarding my problem I have this kind of data file.txt 111111111,20 111111111,50 222222222,70 333333333,40 444444444,10 444444444,20 I need to get this file1.txt 111111111,70 222222222,70 333333333,40 444444444,30 using this code I can... (6 Replies)
Discussion started by: reks
6 Replies

6. Shell Programming and Scripting

Add sum of columns and max as new row

Hi, I am a new bie i need some help with respect to shell onliner; I have data in following format Name FromDate UntilDate Active Changed Touched Test 28-03-2013 28-03-2013 1 0.6667 100 Test2 28-03-2013 03-04-2013 ... (1 Reply)
Discussion started by: gangaraju6
1 Replies

7. Shell Programming and Scripting

Evaluate 2 columns, add sum IF two columns satisfy the condition

HI All, I'm embedding SQL query in Script which gives following output: Assignee Group Total ABC Group1 17 PQR Group2 5 PQR Group3 6 XYZ Group1 10 XYZ Group3 5 I have saved the above output in a file. How do i sum up the contents of this output so as to get following output: ... (4 Replies)
Discussion started by: Khushbu
4 Replies

8. UNIX for Beginners Questions & Answers

Group by columns and add sum in new columns

Dear Experts, I have input file which is comma separated, has 4 columns like below, BRAND,COUNTRY,MODEL,COUNT NIKE,USA,DUMMY,5 NIKE,USA,ORIGINAL,10 PUMA,FRANCE,DUMMY,20 PUMA,FRANCE,ORIGINAL,15 ADIDAS,ITALY,DUMMY,50 ADIDAS,ITALY,ORIGINAL,50 SPIKE,CHINA,DUMMY,1O And expected output add... (2 Replies)
Discussion started by: ricky1991
2 Replies

9. Shell Programming and Scripting

Do replace operation and awk to sum multiple columns if another column has duplicate values

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... (12 Replies)
Discussion started by: as7951
12 Replies

10. UNIX for Beginners Questions & Answers

Copy columns from one file into another and get sum of column values and row count

I have a file abc.csv, from which I need column 24(PurchaseOrder_TotalCost) to get the sum_of_amounts with date and row count into another file say output.csv abc.csv- UTF-8,,,,,,,,,,,,,,,,,,,,,,,,, ... (6 Replies)
Discussion started by: Tahir_M
6 Replies
Explode(3pm)						User Contributed Perl Documentation					      Explode(3pm)

NAME
MIME::Explode - Perl extension for explode MIME messages SYNOPSIS
use MIME::Explode; my $explode = MIME::Explode->new( output_dir => "tmp", mkdir => 0755, decode_subject => 1, check_content_type => 1, content_types => ["image/gif", "image/jpeg", "image/bmp"], types_action => "exclude" ); print "Number of messages: ", $explode->nmsgs, " "; open(MAIL, "<file.mbox") or die("Couldn't open file.mbox for reading: $! "); open(OUTPUT, ">file.tmp") or die("Couldn't open file.tmp for writing: $! "); my $headers = $explode->parse(*MAIL, *OUTPUT); close(OUTPUT); close(MAIL); for my $part (sort{ $a cmp $b } keys(%{$headers})) { for my $k (keys(%{$headers->{$part}})) { if(ref($headers->{$part}->{$k}) eq "ARRAY") { for my $i (0 .. $#{$headers->{$part}->{$k}}) { print "$part => $k => $i => ", $headers->{$part}->{$k}->[$i], " "; } } elsif(ref($headers->{$part}->{$k}) eq "HASH") { for my $ks (keys(%{$headers->{$part}->{$k}})) { if(ref($headers->{$part}->{$k}->{$ks}) eq "ARRAY") { print "$part => $k => $ks => ", join(($ks eq "charset") ? " " : "", @{$headers->{$part}->{$k}->{$ks}}), " "; } else { print "$part => $k => $ks => ", $headers->{$part}->{$k}->{$ks}, " "; } print "$part => $k => $ks => ", $headers->{$part}->{$k}->{$ks}, " "; } } else { print "$part => $k => ", $headers->{$part}->{$k}, " "; } } } if(my $e = $explode->clean_all()) { print "Error: $e "; } DESCRIPTION
MIME::Explode is perl module for parsing and decoding single or multipart MIME messages, and outputting its decoded components to a given directory ie, this module is designed to allows users to extract the attached files out of a MIME encoded email messages or mailboxes. METHODS
new([, OPTION ...]) This method create a new MIME::Explode object. The following keys are available: output_dir Directory where the decoded files are placed mkdir => octal_number If the value is set to octal number then make the output_dir directory (example: mkdir => 0755). check_content_type => 0 or 1 If the value is set to 1 the content-type of file is checked decode_subject => 0 or 1 If the value is set to 1 then the subject is decoded into a list. $header->{'0.0'}->{subject}->{value} = [ARRAYREF]; $header->{'0.0'}->{subject}->{charset} = [ARRAYREF]; $subject = join("", @{$header->{'0.0'}->{subject}->{value}}); exclude_types => [ARRAYREF] Not save files with specified content types (deprecated in next versions) content_types => [ARRAYREF] Array reference with content types for "include" or "exclude" types_action => "include" or "exclude" If the action is a "include", all attached files with specified content types are saved but if the action is a "exclude", no files are saved except if its in the array of content types. If no array is specified, but the action is a "include", all attached files are saved, otherwise all files are removed if action is a "exclude". The default action is "include". parse(FILEHANDLE, FILEHANDLE) This method parse the stream and splits it into its component entities. This method return a hash reference with all parts. The FILEHANDLE should be a reference to a GLOB. The second argument is optional. nmsgs Returns the number of parsed messages. clean_all Cleans all files from the "output_dir" directory and then removes the directory. If an error happens returns it. AUTHOR
Henrique Dias <henrique.ribeiro.dias@gmail.com> CREDITS
Thanks to Rui Castro for the revision. SEE ALSO
MIME::Tools, perl(1). perl v5.14.2 2011-06-26 Explode(3pm)
All times are GMT -4. The time now is 01:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy