Sponsored Content
Full Discussion: how to sum numbers in column
Top Forums Shell Programming and Scripting how to sum numbers in column Post 56285 by iahveh on Thursday 30th of September 2004 07:50:03 AM
Old 09-30-2004
Bug

ok. i've done it:
akw /text/ file.txt |nawk 'BEGIN {FS="|"}; {print $10"+"}' > file1.log
echo "p" >>file1.log
cat file1.log|dc > file2.log
grep -v "stack empty" file2.log
not the most elegant way but it works Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

getting the sum of numbers

I basically have a file where I had to do a bunch of greps to get a list of numbers example: a file called numbers.txt 10000 10000 superman 10000 batman 10000 10000 grep '100' * | 10000 10000 10000 10000 10000 (2 Replies)
Discussion started by: zerofire123
2 Replies

2. Shell Programming and Scripting

Sum of decimal numbers in column

Hi!!! I have n decimal numbers in column: 1.23 3.45 5.16 . . . How to do arithmetic sum of theese numbers??? Thanks!!!:D (4 Replies)
Discussion started by: tdev457
4 Replies

3. Shell Programming and Scripting

Sum of numbers in three or more files

I have files : cat file1 15 88 44 667 33 4cat file2 445 66 77 3 56 (12 Replies)
Discussion started by: Natalie
12 Replies

4. UNIX for Dummies Questions & Answers

Sum every 3 consecutive numbers in a column

Dear All, I have a file with only one column. And I want to add every 3 consecutive numbers together and print the result. Input File: 21.1 10 10 55 11 99 10 8 4 Expected Output: 41.1 (5 Replies)
Discussion started by: NamS
5 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. Shell Programming and Scripting

Sum of numbers in row

Need help in coding: File with several rows incl. numbers like 1 2 3 4 5 6 7 8 ... How can i build the sum of each row seperately? 10 26 ... Thx for help. Please use CODE tags as required by forum rules! (13 Replies)
Discussion started by: smitty11
13 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
Log::Handler::Config(3pm)				User Contributed Perl Documentation				 Log::Handler::Config(3pm)

NAME
Log::Handler::Config - The main config loader. SYNOPSIS
use Log::Handler; my $log = Log::Handler->new(); # Config::General $log->config(config => 'file.conf'); # Config::Properties $log->config(config => 'file.props'); # YAML $log->config(config => 'file.yaml'); Or use Log::Handler; my $log = Log::Handler->new(); $log->config( config => 'file.conf' plugin => 'YAML', ); DESCRIPTION
This module makes it possible to load the configuration from a file. The configuration type is determined by the file extension. It's also possible to mix file extensions with another configuration types. PLUGINS
Plugin name File extensions ------------------------------------------ Config::General cfg, conf Config::Properties props, jcfg, jconf YAML yml, yaml If the extension is not defined then "Config::General" is used by default. METHODS
config() With this method it's possible to load the configuration for your outputs. The following options are valid: config With this option you can pass a file name or the configuration as a hash reference. $log->config(config => 'file.conf'); # or $log->config(config => \%config); plugin With this option it's possible to say which plugin you want to use. Maybe you want to use the file extension "conf" with "YAML", which is reserved for the plugin "Config::General". Examples: # this would use Config::General $log->config( config => 'file.conf' ); # this would force .conf with YAML $log->config( config => 'file.conf', plugin => 'YAML' ); section If you want to write the configuration into a global configuration file then you can create a own section for the logger: <logger> <file> filename = file.log minlevel = emerg maxlevel = warning </file> <screen> minlevel = emerg maxlevel = debug </screen> </logger> <another_script_config> foo = bar bar = baz baz = foo </another_script_config> Now your configuration is placed in the "logger" section. You can load this section with $log->config( config => 'file.conf', section => 'logger', ); # or if you load the configuration yourself to %config $log->config( config => \%config, section => 'logger', ); # or just $log->config( config => $config{logger} ); PLUGINS
Config::General - inspired by the well known apache config format Config::Properties - Java-style property files YAML - optimized for human readability EXAMPLES
Config structures A very simple configuration looks like: $log->config(config => { file => { alias => 'file1', filename => 'file1.log', maxlevel => 'info', minlevel => 'warn', }, screen => { alias => 'screen1', maxlevel => 'debug', minlevel => 'emerg', } }); Now, if you want to add another file-output then you can pass the outputs with a array reference: $log->config(config => { file => [ { alias => 'file1, filename => 'file1.log', maxlevel => 'info', minlevel => 'warn', }, { alias => 'file2', filename => 'file2.log', maxlevel => 'error', minlevel => 'emergency', } ], screen => { alias => 'screen1', maxlevel => 'debug', minlevel => 'emerg', }, }); It's also possible to pass the outputs as a hash reference. The hash keys "file1" and "file2" will be used as aliases. $log->config(config => { file => { file1 => { filename => 'file1.log', maxlevel => 'info', minlevel => 'warn', }, file2 => { filename => 'file2.log', maxlevel => 'error', minlevel => 'emergency', } }, screen => { alias => 'screen1', maxlevel => 'debug', minlevel => 'emerg', }, }); If you pass the configuration with the alias as a hash key then it's also possible to pass a section called "default". The options from this section will be used as defaults. $log->config(config => { file => { default => { # defaults for all file-outputs mode => 'append', }, file1 => { filename => 'file1.log', maxlevel => 'info', minlevel => 'warn', }, file2 => { filename => 'file2.log', maxlevel => 'error', minlevel => 'emergency', } }, screen => { alias => 'screen1', maxlevel => 'debug', minlevel => 'emerg', }, }); Examples for the config plugins Config::General <file> alias = file1 fileopen = 1 reopen = 1 permissions = 0640 maxlevel = info minlevel = warn mode = append timeformat = %b %d %H:%M:%S debug_mode = 2 filename = example.log message_layout = '%T %H[%P] [%L] %S: %m' </file> Or <file> <file1> fileopen = 1 reopen = 1 permissions = 0640 maxlevel = info minlevel = warn mode = append timeformat = %b %d %H:%M:%S debug_mode = 2 filename = example.log message_layout = '%T %H[%P] [%L] %S: %m' </file1> </file> YAML --- file: alias: file1 debug_mode: 2 filename: example.log fileopen: 1 maxlevel: info minlevel: warn mode: append permissions: 0640 message_layout: '%T %H[%P] [%L] %S: %m' reopen: 1 timeformat: '%b %d %H:%M:%S' Or --- file: file1: debug_mode: 2 filename: example.log fileopen: 1 maxlevel: info minlevel: warn mode: append permissions: 0640 message_layout: '%T %H[%P] [%L] %S: %m' reopen: 1 timeformat: '%b %d %H:%M:%S' Config::Properties file.alias = file1 file.reopen = 1 file.fileopen = 1 file.maxlevel = info file.minlevel = warn file.permissions = 0640 file.mode = append file.timeformat = %b %d %H:%M:%S file.debug_mode = 2 file.filename = example.log file.message_layout = '%T %H[%P] [%L] %S: %m' Or file.file1.alias = file1 file.file1.reopen = 1 file.file1.fileopen = 1 file.file1.maxlevel = info file.file1.minlevel = warn file.file1.permissions = 0640 file.file1.mode = append file.file1.timeformat = %b %d %H:%M:%S file.file1.debug_mode = 2 file.file1.filename = example.log file.file1.message_layout = '%T %H[%P] [%L] %S: %m' PREREQUISITES
Carp Params::Validate EXPORTS
No exports. REPORT BUGS
Please report all bugs to <jschulz.cpan(at)bloonix.de>. If you send me a mail then add Log::Handler into the subject. AUTHOR
Jonny Schulz <jschulz.cpan(at)bloonix.de>. COPYRIGHT
Copyright (C) 2007-2009 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-11-21 Log::Handler::Config(3pm)
All times are GMT -4. The time now is 11:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy