The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 10-18-2007
rauphelhunter rauphelhunter is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 23
How to perfrom summation for particular delimited field?

Hi,

Please help to share your thought about how to perfrom summation for particular delimited field, and output to the particular file based on

HTML Code:
-rw-r--r--   1 abc   other          3094 Oct 19 09:40 0132019832-ps5_online_cdrm.unl
-rw-r--r--   1 abc   other          1588 Oct 19 09:47 0132019832-ps5_online_cdrn.unl
-rw-r--r--   1 abc   other          2523 Oct 19 09:54 0132019832-ps5_online_cdro.unl
-rw-r--r--   1 abc   other           947 Oct 19 10:01 0132019832-ps5_online_cdrp.unl
-rw-r--r--   1 abc   other          1300 Oct 19 10:09 0132019832-ps5_online_cdrq.unl
-rw-r--r--   1 abc   other           410 Oct 19 10:16 0132019832-ps5_online_cdrr.unl
-rw-r--r--   1 abc   other          4253 Oct 19 10:23 0132019832-ps5_online_cdrs.unl
-rw-r--r--   1 abc   other         10195 Oct 19 10:31 0132019832-ps5_online_cdrt.unl
-rw-r--r--   1 abc   other          1053 Oct 19 10:38 0132019832-ps5_online_cdru.unl
Each file will have content like this in which separated with delimiter "|".
HTML Code:
1603823|010|4|CDR|0132019832|||3002|0194212739|||||||N|Y|Y|2007-08-30 23:42:42|||17||-0.1|16.5951|||MO019|-0.1|16.5951|0|||
1603863|010|4|CDR|0132019832|||3002|01997564444|||||||N|Y|Y|2007-08-30 23:42:53|||14||-0.1|16.4251|||MO019|-0.1|16.4251|0|||
1603912|010|4|CDR|0132019832|||3005|0135305303|||||||N|Y|Y|2007-08-30 23:43:07|||9||-0.1|16.1851||3GMid|MO013|-0.1|16.1851|0|||
1603930|010|4|CDR|0132019832|||3002|0192504561|||||||N|Y|Y|2007-08-30 23:43:13|||17||-0.1|16.0851|||MO019|-0.1|16.0851|0|||
1603948|010|4|CDR|0132019832|||3004|0126440226|||||||N|Y|Y|2007-08-30 23:43:18|||15||-0.2|15.8851|||MO012|-0.2|15.8851|0|||
1603975|010|4|CDR|0132019832|||3007|0175152680|||||||N|Y|Y|2007-08-30 23:43:28|||13||-0.2|15.6151|||MO017|-0.2|15.6151|0|||
1603996|010|4|CDR|0132019832|||3004|0125329005|||||||N|Y|Y|2007-08-30 23:43:34|||18||-0.2|15.4151|||MO012|-0.2|15.4151|0|||
1604034|010|4|CDR|0132019832|||3005|0137508649|||||||N|Y|Y|2007-08-30 23:43:44|||11||-0.1|15.2451|||MO013|-0.1|15.2451|0|||
The ultimate result of all values in field 24 will be summed up and output to file say a.txt ,while field 5 and total sum value must be separated by "|"

Say when cat output(a.txt)
0132019832| -1.1


Need help...!