Sponsored Content
Top Forums Shell Programming and Scripting Adding values then consolidating lines Post 94765 by tdavenpo on Tuesday 3rd of January 2006 08:53:45 PM
Old 01-03-2006
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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

adding values with a loop

Hi there, I am checking disk spaced used on a box # df -k | grep dsk | awk {'print $3'} 2055463 20165785 18310202 32274406 I want to somehow add them up but am no quite sure how to do this in a loop. ...i.e for n in 'df -k | grep dsk | awk {'print $3}' do <some adding... (1 Reply)
Discussion started by: hcclnoodles
1 Replies

2. Shell Programming and Scripting

Adding the values of two file

I have two files as Count1 and Count2. The count contains only one values as 10 and count2 contains only one values as 20. Now I want third file Count3 as count1+Count2. That is it should contain sum of two file(10+20=30) (3 Replies)
Discussion started by: Shell_Learner
3 Replies

3. Shell Programming and Scripting

Adding values concatenating values

I have the following script in a shell # The start of a filename file=$(ls -tr $EMT*.dat | tail -1) # Select the latest file echo $file file_seq=$( < /u02/sct/banner/bandev2/xxxxxx/misc/EFTSQL.dat) echo $file_seq file2 = '$file_seq + 1' echo $file2 It is reading a file EFTSQL.dat... (3 Replies)
Discussion started by: rechever
3 Replies

4. Shell Programming and Scripting

dynamically adding values in c-shell

I am needing to create a variable(changing) and assign it a value(changing) ... I am using C-Shell.. Example: foreach account in ($Accountlist) set account_connect = "$account/$account_pass" end I want to make set account_connect to store various values ? $account_connect did not... (3 Replies)
Discussion started by: shafi2all
3 Replies

5. Shell Programming and Scripting

Adding new lines to a file + adding suffix to a pattern

I need some help with adding lines to file and substitute a pattern. Ok I have a file: #cat names.txt name: John Doe stationed: 1 name: Michael Sweets stationed: 41 . . . And would like to change it to: name: John Doe employed permanently stationed: 1-office (7 Replies)
Discussion started by: hemo21
7 Replies

6. Shell Programming and Scripting

Adding prefix to the values in the script

Hi, test.txt contains below values 1 2 3 4 5 Desired output: 'TT.1', 'TT.2', 'TT.3', 'TT.4', 'TT.5' Last value should not contain the comma after the value. Below is the script which i have tried. I'm using Linux. #!/bin/bash for i in $test.txt (4 Replies)
Discussion started by: venkatesht
4 Replies

7. Shell Programming and Scripting

Adding values returned through foreach

Hi Folks I wanted to do something like this : Go through all the top_level_dirs inside a particular dir. Grep a particular string in the files in each of those dirs. Count the occurence of that string in that file Keep adding these (wc) values so that I can know the total occurences of that... (1 Reply)
Discussion started by: abcdino
1 Replies

8. UNIX for Dummies Questions & Answers

Adding column with values

Dear all, I need your help for my question please I have without header (space separated) and need to add two colomns at the beginning with values my file look like : rs1 a t 0.6 rs2 a c 0.3 rs3 t g 0.8 I need to a new file like: 1 100 rs1 a t 0.6 1 100 rs2 a c 0.3 1 100 rs3 t g... (3 Replies)
Discussion started by: biopsy
3 Replies

9. Shell Programming and Scripting

Adding of two column values

Hi cat /tmp/xx.txt 1 4 1 5 1 6 2 1 2 1 2 1 i want to add the values of 2nd column resepect to 1st column values..for 1 in 1st column i need sum of all the values in 2nd column ..pls tell me hw to do it?? (8 Replies)
Discussion started by: Aditya.Gurgaon
8 Replies

10. Shell Programming and Scripting

Adding the values of repeated ids

File1 consist two columns, first some weired ids and second the numbers t|v203.1@t|k88711.1 0.1 t|v190.1@t|k90369.1 0.01 t|v203.1@t|k88711.1 0.5 t|v322.1@t|k88711.1 0.2 t|v207.1@t|k90369.1 0.11 t|v326.1@t|k85939.1 0.5 t|v207.1@t|k90369.1 0.7 t|v207.1@t|k90369.1 0.3 t|v326.1@t|k89421.1 0.33... (3 Replies)
Discussion started by: ashmit99
3 Replies
COMM(1) 							   User Commands							   COMM(1)

NAME
comm - compare two sorted files line by line SYNOPSIS
comm [OPTION]... FILE1 FILE2 DESCRIPTION
Compare sorted files FILE1 and FILE2 line by line. With no options, produce three-column output. Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and column three contains lines common to both files. -1 suppress lines unique to FILE1 -2 suppress lines unique to FILE2 -3 suppress lines that appear in both files --check-order check that the input is correctly sorted, even if all input lines are pairable --nocheck-order do not check that the input is correctly sorted --output-delimiter=STR separate columns with STR --help display this help and exit --version output version information and exit AUTHOR
Written by Richard M. Stallman and David MacKenzie. REPORTING BUGS
Report comm bugs to bug-coreutils@gnu.org GNU coreutils home page: <http://www.gnu.org/software/coreutils/> General help using GNU software: <http://www.gnu.org/gethelp/> COPYRIGHT
Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
The full documentation for comm is maintained as a Texinfo manual. If the info and comm programs are properly installed at your site, the command info coreutils 'comm invocation' should give you access to the complete manual. GNU coreutils 7.1 July 2010 COMM(1)
All times are GMT -4. The time now is 01:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy