Sponsored Content
Full Discussion: Sum value using sed or awk ?
Top Forums Shell Programming and Scripting Sum value using sed or awk ? Post 302942806 by crazy_max on Friday 1st of May 2015 01:20:22 PM
Old 05-01-2015
Sum value using sed or awk ?

Hello all,

how would one go about writing a command using sed/awk that will give me an output that can sum up the number of time each user has done something and also add the amount of time...

so output would be for example
"
Code:
smiths has run 3 process and for time taken of value: 224

"

here is the sample data (username | Process name | Time taken)...

Code:
smiths|Login|2
olivert|Login|2
northj|Login|2
denniss|Login|2
smithd|Login|2
smiths|Time Reporting|210
olivert|Payroll|155
northj|Server Maintenance|70
northj|Logfile Reporting|45
denniss|Report Printing|80
smithd|Payroll Program Updates|150
smithd|Benefit Program Updates|180
smiths|Logout|2
olivert|Logout|2
northj|Logout|2
denniss|Logout|2
smithd|Logout|2


Last edited by Scrutinizer; 05-01-2015 at 02:34 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help sum columns by break in first column with awk or sed or something.

I have some data that is something like this? item: onhand counted location ITEM0001 1 0 a1 ITEM0001 0 1 a2 ITEM0002 5 0 b5 ITEM0002 0 6 c1 I want to sum up... (6 Replies)
Discussion started by: syadnom
6 Replies

2. Shell Programming and Scripting

Sum with awk

Hi,consider this fields, $1 $2 $3 981 0 1 984 0 4 985 1 0 987 0 2 990 0 0 993 0 3 995 2 0 996 0 1 999 0 4 for each occurence of zero in column $2 and $3 I need to sum $1 fields, so for example, in this piece of code the result of $1 is 8910. I'm sure... (2 Replies)
Discussion started by: cv313x
2 Replies

3. Shell Programming and Scripting

scripting/awk help : awk sum output is not comming in regular format. Pls advise.

Hi Experts, I am adding a column of numbers with awk , however not getting correct output: # awk '{sum+=$1} END {print sum}' datafile 2.15291e+06 How can I getthe output like : 2152910 Thank you.. # awk '{sum+=$1} END {print sum}' datafile 2.15079e+06 (3 Replies)
Discussion started by: rveri
3 Replies

4. Shell Programming and Scripting

Sum using awk

Hi all, I need to sum values for fields in a delimited file as below: 2010-03-05||| 2010-03-05|||123 2010-03-05|467.621|369.532| 2010-03-06||| 2010-03-06||2| 2010-03-06|||444 2010-03-07||| 2010-03-07||| 2010-03-07|655.456|1019.301| Code used is: nawk -F "|" ' { sum +=... (7 Replies)
Discussion started by: Katabatic
7 Replies

5. UNIX for Dummies Questions & Answers

awk question about sum

Hi everyone, i need help with a simple task. I have a file withe the format: "01/20/2012 23:10:13.979","49","49","48","19" "01/20/2012 23:15:13.969","47","47","48","18" "01/20/2012 23:20:13.975","47","47","45","17" "01/20/2012 23:25:13.980","44","44","44","17" "01/20/2012... (3 Replies)
Discussion started by: civilianwarfare
3 Replies

6. Shell Programming and Scripting

awk and count sum ?

I have a input.txt file which have 3 fields separate by a comma place, os and timediff in seconds tampa,win7, 2575 tampa,win7, 157619 tampa,win7, 3352 dallas,vista,604799 greenbay,winxp, 14400 greenbay,win7 , 518400 san jose,winxp, 228121 san jose,winxp, 70853 san jose,winxp, 193514... (5 Replies)
Discussion started by: sabercats
5 Replies

7. Shell Programming and Scripting

Summing over specific lines and replacing the lines with the sum using sed, awk

Hi friends, This is sed & awk type question. I have a text file which has numbers spread all over the file. I want to sum the series of numbers whenever i find it and produce an output file with the sum. For example ###start of input text file #### abc def ghi 1 2 3 4 kjld random... (3 Replies)
Discussion started by: kaaliakahn
3 Replies

8. Shell Programming and Scripting

sum from ls -al |awk '{print $5}'

// AIX 5.3 & AIX 6.1 ls -al |awk '{print $5}' This gives each file's size in byte. I need to get: - the sum of all files in Giga bytes with loop. - excluding the size of directories (ls -al returns the size of directories). There are hundreds and thousands of files, so summing up... (8 Replies)
Discussion started by: Daniel Gate
8 Replies

9. Shell Programming and Scripting

awk and or sed command to sum the value in repeating tags in a XML

I have a XML in which <Amt Ccy="EUR">3.1</Amt> tag repeats. This is under another tag <Main>. I need to sum all the values of <Amt Ccy=""> (Ccy may vary) coming under <Main> using awk and or sed command. can some help? Sample looks like below <root> <Main> ... (6 Replies)
Discussion started by: bk_12345
6 Replies

10. Shell Programming and Scripting

awk and sum

This is my file vol0 285GB vol0.snapshot 15GB vol11_root 0GB vol12_root 47GB vol12_root.snapshot 2GB I need the output vol0 285GB,vol0.snapshot 15GB,sum-300GB vol11_root 0GB,nosnap,sum-0Gb vol12_root 47GB,vol12_root.snapshot 2GB,49GB I was trying to use paste -d, --. But... (9 Replies)
Discussion started by: ranjancom2000
9 Replies
CatalystX::SimpleLogin(3pm)				User Contributed Perl Documentation			       CatalystX::SimpleLogin(3pm)

NAME
CatalystX::SimpleLogin - Provide a simple Login controller which can be reused SYNOPSIS
package MyApp; use Moose; use namespace::autoclean; use Catalyst qw/ +CatalystX::SimpleLogin Authentication Session Session::State::Cookie Session::Store::File /; extends 'Catalyst'; __PACKAGE__->config( 'Plugin::Authentication' => { # Auth config here } ); __PACKAGE__->config( 'Controller::Login' => { # SimpleLogin config here } ); __PACKAGE__->setup; ATTENTION! If you're new here, you should start by reading CatalystX::SimpleLogin::Manual, which provides a gentler introduction to using this code. Come back here when you're done there. DESCRIPTION
CatalystX::SimpleLogin is an application class Moose::Role which will inject a Catalyst::Controller which is an instance of CatalystX::SimpleLogin::Controller::Login into your application. This provides a simple login and logout page with the adition of only one line of code and one template to your application. REQUIREMENTS
A Catalyst application Working authentication configuration Working session configuration A view CUSTOMISATION
CatalystX::SimpleLogin is a prototype for CatalystX::Elements. As such, one of the goals is to make it easy for users to customise the provided component to the maximum degree possible, and also, to have a linear relationship between effort invested and level of customisation achieved. Three traits are shipped with SimpleLogin: WithRedirect, Logout, and RenderAsTTTemplate. These traits are set in the config: __PACKAGE__->config( 'Controller::Login' => { traits => [qw/ Logout WithRedirect RenderAsTTTemplate /], login_form_args => { # see the login form }, ); COMPONENTS
o CatalystX::SimpleLogin::Controller::Login - first point of call for customisation. Override the action configs to reconfigure the paths of the login or logout actions. Subclass to be able to apply method modifiers to run before / after the login or logout actions or override methods. o CatalystX::SimpleLogin::TraitFor::Controller::Login::Logout - provides the "logout" action and associated methods. You can compose this manually yourself if you want just that action. This trait is set by default, but if you set another trait in your config, you will have to include it. o CatalystX::SimpleLogin::TraitFor::Controller::Login::WithRedirect - provides the "login" action with a wrapper to redirect to a page which needs authentication, from which the user was previously redirected. Goes hand in hand with Catalyst::ActionRole::NeedsLogin o CatalystX::SimpleLogin::TraitFor::Controller::Login::RenderAsTTTemplate - sets the stash variable 'template' to point to a string reference containing the rendered template so that it's not necessary to have a login.tt template file. o CatalystX::SimpleLogin::Form::Login - the HTML::FormHandler form for the login form. o Catalyst::ActionRole::NeedsLogin - Used to cause a specific path to redirect to the login page if a user is not authenticated. TODO
Here's a list of what I think needs working on, in no particular order. Please feel free to add to or re-arrange this list :) Fix extension documentation Document all this stuff. Examples of use / customisation in documentation Fixing one uninitialized value warning in LoginRedirect Disable the use of NeedsLogin ActionRole when WithRedirect is not loaded SOURCE CODE
http://github.com/bobtfish/catalystx-simplelogin/tree/master git://github.com/bobtfish/catalystx-simplelogin.git Forks and patches are welcome. #formhandler or #catalyst (irc.perl.org) are both good places to ask about using or developing this code. SEE ALSO
o Catalyst o Moose and Moose::Role o MooseX::MethodAttributes::Role - Actions composed from Moose::Role. o CatalystX::InjectComponent - Injects the controller class o HTML::FormHandler - Generates the login form o Catalyst::Plugin::Authentication - Responsible for the actual heavy lifting of authenticating the user o Catalyst::Plugin::Session o Catalyst::Controller - Allows you to decorate actions with roles (E.g Catalyst::ActionRole::NeedsLogin) o CatalystX::Component::Traits - Allows Moose::Role to be composed onto components from config AUTHORS
Tomas Doran (t0m) "bobtfish@bobtfish.net" Zbigniew Lukasiak Stephan Jauernick (stephan48) "stephan@stejau.de" Gerda Shank (gshank) "gshank@cpan.org" Florian Ragwitz "rafl@debian.org" Shlomi Fish Oleg Kostyuk (cub-uanic) "cub@cpan.org" LICENSE
Copyright 2009 Tomas Doran. Some rights reserved. This sofware is free software, and is licensed under the same terms as perl itself. perl v5.14.2 2012-07-15 CatalystX::SimpleLogin(3pm)
All times are GMT -4. The time now is 07:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy