Sponsored Content
Full Discussion: How to get sub_total
Top Forums Shell Programming and Scripting How to get sub_total Post 302472157 by Chubler_XL on Tuesday 16th of November 2010 12:10:23 PM
Old 11-16-2010
Using awk:

Code:
awk -F"[, ]" ' 
/ID,/ { print "ID BUDGET_MON BUDGET_AMT" }
!/ID,/ {
   for(i=2;i<NF;i++) print $1, $i,$NF/(NF-2);
}' budget.txt

Using bash/ksh
Code:
echo "ID BUDGET_MON BUDGET_AMT"
while read ID MONTHS VAL
do
   read -a M_ARRAY <<EOF
   $( IFS=","; echo $MONTHS )
EOF
   [ "$ID" = "ID," ] && continue
   for MTH in ${M_ARRAY[@]}
   do
       echo $ID $MTH $((VAL/${#M_ARRAY[@]}))
   done
done < budget.txt

This User Gave Thanks to Chubler_XL For This Post:
 
Graphics::Primitive::Insets(3pm)			User Contributed Perl Documentation			  Graphics::Primitive::Insets(3pm)

NAME
Graphics::Primitive::Insets - Space between things DESCRIPTION
Graphics::Primitive::Insets represents the amount of space that surrounds something. This object can be used to represent either padding or margins (in the CSS sense, one being inside the bounding box, the other being outside) SYNOPSIS
use Graphics::Primitive::Insets; my $insets = Graphics::Primitive::Insets->new({ top => 5, bottom => 5, left => 5, right => 5 }); METHODS
Constructor new Creates a new Graphics::Primitive::Insets. Instance Methods as_array Return these insets as an array in the form of top, right, bottom and left. bottom Set/Get the inset from the bottom. equal_to Determine if these Insets are equal to another. left Set/Get the inset from the left. right Set/Get the inset from the right. top Set/Get the inset from the top. zero Sets all the insets (top, left, bottom, right) to 0. AUTHOR
Cory Watson, "<gphat@cpan.org>" SEE ALSO
perl(1) COPYRIGHT &; LICENSE Copyright 2008-2010 by Cory G Watson. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2010-08-21 Graphics::Primitive::Insets(3pm)
All times are GMT -4. The time now is 11:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy