Sponsored Content
Full Discussion: Calculate the total
Top Forums Shell Programming and Scripting Calculate the total Post 302888295 by ctsgnb on Thursday 13th of February 2014 04:33:40 PM
Old 02-13-2014
You can get the needed data in a lazy way (i have no doubt it may be improved) but you can go with something like :
Code:
grep -E "^" aaa*.log | sed 's/.log:/ /;s/^[^0-9]*//' | awk '{a[$2" "$1]++}END{for(i in a) print i, a[i]}' | sort -k 1

or
Code:
$ grep -E "^" aaa*.log | sed 's/\(..\).log:/ \1 /;s/^[^0-9]*//' | uniq -c | awk '{a[$4" "$2]+=$1;print}END{for(i in a)print "Tot",i,"=",a[i]}'
      2 2014 01 aaa  111
      2 2014 01 bbb  222
      4 2014 02 aaa  111
      5 2014 02 bbb  222
Tot aaa 2014 = 6
Tot bbb 2014 = 7

The formatting is then just a matter of cosmetic

Last edited by ctsgnb; 02-13-2014 at 06:13 PM..
 

8 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

Calculate total sum from a file

The file content is dynamic and using this format: name1 number1 name2 number2 name3 number3 name4 number4 .................... Need a smooth way to calculate the sum of all the numbers in that file (number1 + number2 + number3 + number4........ = total ) (11 Replies)
Discussion started by: TehOne
11 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

Calculate total of log by hour

Hi, Just wondering, is there anyway I can get the total of logs generated by hours ? Let say I have these logs, Sep 23 04:48:43 hsbcufs: NOTICE: realloccg /: file system full Sep 23 04:48:47 hsbcufs: NOTICE: alloc: /: file system full Sep 23 04:48:51 hsbcufs: NOTICE: realloccg /: file... (14 Replies)
Discussion started by: dehetoxic
14 Replies

6. Shell Programming and Scripting

Calculate total value from a row

HI I have a file # cat marks.txt MARKS LIST 2013 Name english french chinese latin total_marks wer 34 45 67 23 wqa 12 39 10 56 wsy 23 90 23 78 Now i need to find the total marks of each student using... (11 Replies)
Discussion started by: Priya Amaresh
11 Replies

7. Shell Programming and Scripting

Calculate the total 4 field based on the conditions

Please help me to write a script Match with ACNO & NAME if it matched calculate the total val1 val2 val3 and val4 and GT is total of ACNO wise.please check the output Table ----------------- 1005|ANDP|ACN|20|50|10|30 1005|ANDP|ACN|20|10|30|40 1001|AND|NAC|40|50|40|50... (22 Replies)
Discussion started by: kalia4u
22 Replies

8. Shell Programming and Scripting

Calculate total memory using free -m

Hi I am trying to calculate memory used by Linux System free -m total used free shared buffers cached Mem: 32109 31010 1099 0 3600 7287 -/+ buffers/cache: 20121 11987 Swap: 10239 1282 8957 Now according to my requirement Im calculating memory using below cmd free -m | awk 'NR==3{printf... (2 Replies)
Discussion started by: sam@sam
2 Replies
Locale::Po4a::Sgml(3)					User Contributed Perl Documentation				     Locale::Po4a::Sgml(3)

NAME
Locale::Po4a::Sgml - convert SGML documents from/to PO files DESCRIPTION
The po4a (PO for anything) project goal is to ease translations (and more interestingly, the maintenance of translations) using gettext tools on areas where they were not expected like documentation. Locale::Po4a::Sgml is a module to help the translation of documentation in the SGML format into other [human] languages. This module uses nsgmls to parse the SGML files. Make sure it is installed. Also make sure that the DTD of the SGML files are installed in the system. OPTIONS ACCEPTED BY THIS MODULE
debug Space separated list of keywords indicating which part you want to debug. Possible values are: tag, generic, entities and refs. verbose Give more information about what's going on. translate Space separated list of extra tags (beside the DTD provided ones) whose content should form an extra msgid. section Space separated list of extra tags (beside the DTD provided ones) containing other tags, some of them being of category translate. indent Space separated list of tags which increase the indentation level. verbatim The layout within those tags should not be changed. The paragraph won't get wrapped, and no extra indentation space or new line will be added for cosmetic purpose. empty Tags not needing to be closed. ignore Tags ignored and considered as plain char data by po4a. That is to say that they can be part of an msgid. For example, <b> is a good candidate for this category since putting it in the translate section would create msgids not being whole sentences, which is bad. attributes A space separated list of attributes that need to be translated. You can specify the attributes by their name (for example, "lang"), but you can also prefix it with a tag hierarchy, to specify that this attribute will only be translated when it is into the specified tag. For example: <bbb><aaa>lang specifies that the lang attribute will only be translated if it is in an <aaa> tag, which is in a <bbb> tag. The tag names are actually regular expressions so you can also write things like <aaa|bbbb>lang to only translate lang attributes that are in an <aaa> or a <bbb> tag. qualify A space separated list of attributes for which the translation must be qualified by the attribute name. Note that this setting automatically adds the given attribute into the 'attributes' list too. force Proceed even if the DTD is unknown or if nsgmls finds errors in the input file. include-all By default, msgids containing only one entity (like '&version;') are skipped for the translator comfort. Activating this option prevents this optimisation. It can be useful if the document contains a construction like "<title>&Aacute;</title>", even if I doubt such things to ever happen... ignore-inclusion Space separated list of entities that won't be inlined. Use this option with caution: it may cause nsgmls (used internally) to add tags and render the output document invalid. STATUS OF THIS MODULE
The result is perfect. I.e., the generated documents are exactly the same. But there are still some problems: o The error output of nsgmls is redirected to /dev/null, which is clearly bad. I don't know how to avoid that. The problem is that I have to "protect" the conditional inclusions (i.e. the "<! [ %foo [" and "]]>" stuff) from nsgmls. Otherwise nsgmls eats them, and I don't know how to restore them in the final document. To prevent that, I rewrite them to "{PO4A-beg-foo}" and "{PO4A-end}". The problem with this is that the "{PO4A-end}" and such I add are valid in the document (not in a <p> tag or so). Everything works well with nsgmls's output redirected that way, but it will prevent us from detecting that the document is badly formatted. o It does work only with the DebianDoc and DocBook DTD. Adding support for a new DTD should be very easy. The mechanism is the same for every DTD, you just have to give a list of the existing tags and some of their characteristics. I agree, this needs some more documentation, but it is still considered as beta, and I hate to document stuff which may/will change. o Warning, support for DTDs is quite experimental. I did not read any reference manual to find the definition of every tag. I did add tag definition to the module 'till it works for some documents I found on the net. If your document use more tags than mine, it won't work. But as I said above, fixing that should be quite easy. I did test DocBook against the SAG (System Administrator Guide) only, but this document is quite big, and should use most of the DocBook specificities. For DebianDoc, I tested some of the manuals from the DDP, but not all yet. o In case of file inclusion, string reference of messages in PO files (i.e. lines like "#: en/titletoc.sgml:9460") will be wrong. This is because I preprocess the file to protect the conditional inclusion (i.e. the "<! [ %foo [" and "]]>" stuff) and some entities (like &version;) from nsgmls because I want them verbatim to the generated document. For that, I make a temp copy of the input file and do all the changes I want to this before passing it to nsgmls for parsing. So that it works, I replace the entities asking for a file inclusion by the content of the given file (so that I can protect what needs to be in a subfile also). But nothing is done so far to correct the references (i.e., filename and line number) afterward. I'm not sure what the best thing to do is. AUTHORS
This module is an adapted version of sgmlspl (SGML postprocessor for the SGMLS and NSGMLS parsers) which was: Copyright (c) 1995 by David Megginson <dmeggins@aix1.uottawa.ca> The adaptation for po4a was done by: Denis Barbier <barbier@linuxfr.org> Martin Quinson (mquinson#debian.org) COPYRIGHT AND LICENSE
Copyright (c) 1995 by David Megginson <dmeggins@aix1.uottawa.ca> Copyright 2002, 2003, 2004, 2005 by SPI, inc. This program is free software; you may redistribute it and/or modify it under the terms of GPL (see the COPYING file). perl v5.14.2 2012-05-17 Locale::Po4a::Sgml(3)
All times are GMT -4. The time now is 03:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy