Sponsored Content
Full Discussion: awk for total
Top Forums Shell Programming and Scripting awk for total Post 302742289 by Joseph_TKLee on Monday 10th of December 2012 11:08:55 PM
Old 12-11-2012
Tested it successfully.
Code:
 
cat input.txt | awk '{ if ( $2 ~ /T$/ ) Total+=substr($2,1,length($2)-1)*1000000; else if ( $2 ~/G$/ ) Total+=substr($2,1,length($2)-1)*1000; else Total+=substr($2,1,length($2)-1) } END { print Total "MB"}'

Cheers,
This User Gave Thanks to Joseph_TKLee For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk help needed to calculate total

Hi all, I have a flat file like 10 steven 25 mike 47 Charles 127 Nancy 34 steven 23 mike 67 Charles 7761 Nancy 8 steven 54 mike 88 Charles 1267 Nancy I need to calculate the total of steven and all the members , for this I am using like grep "`sed -n 1p patterns.txt`"... (7 Replies)
Discussion started by: senthilkumar_ak
7 Replies

2. 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

3. Shell Programming and Scripting

Finding the total of a column using awk

Here is my file name countries USSR 8650 262 Asia Canada 3852 24 North America China 3692 866 Asia USA 3615 219 North America Brazil 3286 116 South America India 1269 637 Asia Argentina 1072 ... (8 Replies)
Discussion started by: ironhead3fan
8 Replies

4. 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

5. Shell Programming and Scripting

awk total and print if

hi all! I have a space delimited file... I would like to total column 3 on the condition that column 2 is less than 1030 to a variable in my script something like this: TOTAL="`awk '{$2 < 1030} {s+=$3}END{print s}' file`" Seem to be ignoring the {$2 < 1030}, I'm not sure of the... (3 Replies)
Discussion started by: lyoncc
3 Replies

6. Shell Programming and Scripting

How to get total time using awk

Hi guys, I can't find a solution to sum the h:m:s: columns. 28/05/2010 03h 29min 34seg ADSL TELEMAR 28/05/2010 12h 19min 21seg ADSL TELEMAR 29/05/2010 04h 20min 02seg ADSL TELEMAR 29/05/2010 04h 31min 45seg ADSL TELEMAR 30/05/2010 06h 10min 43seg ADSL TELEMAR Thanks Use code... (8 Replies)
Discussion started by: ashimada
8 Replies

7. Shell Programming and Scripting

Awk total and variance

File1 0358 Not Visible ***:* NA:NA RDF1+TDEV Grp'd (M) RW 102413 0359 Not Visible ***:* NA:NA RDF1+TDEV N/Grp'd (m) RW - 035A Not Visible ***:* NA:NA RDF1+TDEV N/Grp'd (m) RW - 035B Not Visible ***:* NA:NA ... (2 Replies)
Discussion started by: greycells
2 Replies

8. Shell Programming and Scripting

Total Count using AWK

Hi Everybody, I have the following example file... 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1... (8 Replies)
Discussion started by: sraj142
8 Replies

9. Shell Programming and Scripting

awk adjustment to print total

im trying to print all lines in the /var/log/syslog file that contain the pattern CRON. and after all the lines have been printed, i want a total of all the lines that contained "CRON" to be printed at the end. the below command is printing the correct lines, but it is giving me the sum of all... (1 Reply)
Discussion started by: SkySmart
1 Replies
Net::Google::Code::Issue::Comment(3pm)			User Contributed Perl Documentation		    Net::Google::Code::Issue::Comment(3pm)

NAME
Net::Google::Code::Issue::Comment - Issue's Comment DESCRIPTION
ATTRIBUTES
project project name email, password user's email and password issue_id sequence sequence number, initial comment( when you create an issue ) has sequence 0 date content author updates HashRef that reflects updates attachments INTERFACE
parse( HTML::Element or html segment string ) parse format like the following: <td class="vt issuecomment"> <span class="author">Comment <a name="c18" href="#c18">18</a> by <a href="/u/jsykari/">jsykari</a></span>, <span class="date" title="Wed Sep 3 04:44:39 2008">Sep 03, 2008</span> <pre> <b>haha</b> </pre> <div class="attachments"> <table cellspacing="0" cellpadding="2" border="0"> <tr><td rowspan="2" width="24"><a href="http://chromium.googlecode.com/issues/attachment?aid=-1323983749556004507&amp;name=proxy_settings.png" target="new"><img width="16" height="16" src="/hosting/images/generic.gif" border="0" ></a></td> <td><b>proxy_settings.png</b></td></tr> <tr><td>14.3 KB <a href="http://chromium.googlecode.com/issues/attachment?aid=-1323983749556004507&amp;name=proxy_settings.png">Download</a></td></tr> </table> </div> <div class="updates"> <div class="round4"></div> <div class="round2"></div> <div class="round1"></div> <div class="box-inner"> <b>Cc:</b> thatan...@google.com<br><b>Status:</b> Available<br><b>Labels:</b> Mstone-X<br> </div> <div class="round1"></div> <div class="round2"></div> <div class="round4"></div> </div> </td> list google's api way to get list of comments return a list of loaded( no scraping is done here ) comments in list context, a ref to the list otherwise. parse_hybrid when $Net::Google::Code::Issue::USE_HYBRID is true, we will try to load comments with the google's official api, but as the api is not complete, we still need to do scraping to load something( e.g. attachments ), this method is used to do this. AUTHOR
sunnavy "<sunnavy@bestpractical.com>" LICENCE AND COPYRIGHT
Copyright 2008-2010 Best Practical Solutions. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-04-07 Net::Google::Code::Issue::Comment(3pm)
All times are GMT -4. The time now is 10:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy