The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
adding values with a loop hcclnoodles Shell Programming and Scripting 1 05-27-2008 03:42 AM
Adding words to beginning of lines Ernst Shell Programming and Scripting 9 04-03-2008 11:23 AM
get lines with multiple values at a position deepakgang Shell Programming and Scripting 9 03-27-2008 01:23 AM
Help in adding positive & negative values in a column berlin_germany Shell Programming and Scripting 4 02-09-2007 02:03 PM
adding text to a file between lines bishweshwar Shell Programming and Scripting 7 10-10-2006 10:03 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-03-2006
Registered User
 

Join Date: Jan 2006
Posts: 2
Adding values then consolidating lines

I'm a begginer with scripting...

Have a script that pulls check information data. There are multiple lines for each check. ALL the info is the same on the line EXCEPT the charges. ie: same check number, same payee, same patient, same check date, DIFFERENT CHARGE. I need to total the charges for the each check number ( there may be 1 line per check number, or 15 lines per check number depending on how many charges there are) and combine the like info to have 1 line per check with the total amount of all the charges. Copy of existing script that pulls the data:

# reformat the luminator report camden to send a check register
# 11/07/05 dvh written
#
# run by entering - camden.sh DATE
#

if [ "$1" = "" ]; then
echo " "
echo " Usage: camden.sh <MMDDYY>"
echo " PRESS ENTER TO CONTINUE..."
read reply
exit 1
fi

DBCU=/u1/luminx/live/dbcdxu
LIVE=/u1/luminx/live
IMPORT=/u1/luminx/live/import
WORK=/u1/luminx/live/work

clear
#
$DBCU/sort $LIVE/work/300$1cl.ecc $IMPORT/300$1.wr1 1-6 -p123-137eq" " -t=text
$DBCU/sort $LIVE/work/300$1cl.ecc $IMPORT/300$1.wr2 1-6 -p123-137ne" " -t=text

# .wr1 is where the patient field is blank
$DBCU/reformat $IMPORT/300$1.wr1 $IMPORT/300$1.wr3 1-6 -b=1 24-25 -f="/" 26-27 -f="/" 20-23 -f=" F" 45-58 81-89 170-170 -b=1 107-121 -b=1 139-147 -b=1 151-152 154-155 157-158 160-163 165-168 197-225 -t=text

# .wr2 is where the patient field is not blank
$DBCU/reformat $IMPORT/300$1.wr2 $IMPORT/300$1.wr3 -a 1-6 -b=1 24-25 -f="/" 26-27 -f="/" 20-23 -f=" F" 45-58 81-89 170-170 -b=1 123-137 -b=1 139-147 -b=1 151-152 154-155 157-158 160-163 165-168 197-225 -t=text

# now sort the file by check #
$DBCU/sort $IMPORT/300$1.wr3 $IMPORT/300$1.txt 1-6 -p1-6ne" " -t=text

rm $IMPORT/300$1.wr1
rm $IMPORT/300$1.wr2
rm $IMPORT/300$1.wr3

# now sort the file by provider and facility
$DBCU/sort $IMPORT/300$1.txt $IMPORT/300$1.wr4 1-6 -p85-108eq" " -t=text

$DBCU/sort $IMPORT/300$1.txt $IMPORT/300$1.wr5 1-6 -p85-108ne" " -t=text

# .wr4 is the provider file


# .wr5 is the facility file
$DBCU/reformat $IMPORT/300$1.wr5 $IMPORT/300$1.wr6 1-6 -b=1 8-17 -b=1 19-19 85-108 -b=1 45-61 62-69 -b=1 71-84 -t=text

cat $IMPORT/300$1.wr4 $IMPORT/300$1.wr6 > $IMPORT/300$1.txt

$DBCU/sort $IMPORT/300$1.txt $IMPORT/300$1.txt 1-6 -p1-6ne" " -t=text

echo "Press enter to continue..."
read reply

HERE IS A SAMPLE OF THE DATA FILE THAT NEEDS TO BE MODIFIED FOR THE ABOVE REQUEST:

012361 11/17/2005 F BLAKE 292.95
012362 11/17/2005 F LANA 9.30
012362 11/17/2005 F LANA .00
012363 11/17/2005 FPEDIATRICS 32.77
012364 11/17/2005 F LORNA 18.00
012364 11/17/2005 F LORNA 16.20
012364 11/17/2005 F LORNA 20.70


Thanks for any help. The first column is the check number, the last is the charge. This is not all the data and IT IS formated in positions. ALL FIELDS ARE IN SAME POSITIONS. I just need to know how to do this.

Tommy
Reply With Quote
Google The UNIX and Linux Forums
Forum Sponsor
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:56 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0