Sponsored Content
Top Forums Shell Programming and Scripting Formatting a report from 2 files Post 302100031 by augustinep on Friday 15th of December 2006 01:37:03 PM
Old 12-15-2006
I am still getting the output in the following manner:

$ more result1
Opening Balance : 100.00
01/03/2006 USD 1000 36.65
01/14/2006 USD 1000 150.00
01/04/2006 USD 1000 2000.00 (should not be printed as the GL is different)
Total Balance : 286.65

Opening Balance : 0.00
01/03/2006 USD 1005 36.65 (should not be printed as the GL is different)
01/14/2006 USD 1005 150.00 (should not be printed as the GL is different)
01/04/2006 USD 1005 2000.00
Total Balance : 2000

It looks like it is not doing a key match or am I doing something wrong.

The following is the script used:
------------------------------
rm result1
while read line
do
gl=`echo $line | cut -d\* -f1`
obal=`echo $line | cut -d\* -f4`
#echo "Opening Balance : $obal" >> result1
cat file2 |awk -F* 'BEGIN{opbl=0}
{if($3 == g){
if(opbl == 0) {
print "Opening Balance :" totbal
opbl=1
}
totbal = totbal + $7
{print $5 " " $6" " g " "$7}
}
}END{print "Total Balance : " totbal"\n" }' g="$gl" totbal="$obal" >>result1
done < file1
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Formatting files

We currently use the following script to format a non formatted file to an 80 byte format (for grep purposes etc..) We need some assistance with converting the file back to a non formatted file with no carriage returns ( we want the file to be a continuous line) #!/usr/local/bin/perl ($fn,... (1 Reply)
Discussion started by: rivera
1 Replies

2. Shell Programming and Scripting

formatting and merging 2 data files

Hi, I have 2 files that I got as an output from another program. They are : File 1 ((((((CtBJa:197.0,CtBTz:197.0):85.0,CtAHr:197.0):116.0,CtDUw:197.0):176.0,CtSwe:197.0):110.0, (CtL2b:197.0,Ct4Bu:197.0):196.0):197.0,CmuNg:197.0);... (5 Replies)
Discussion started by: Lucky Ali
5 Replies

3. Shell Programming and Scripting

formatting files

how do i add the directory name to multiple flies and pad numbers sequences /bin/bin2/bin3/bin4/bin5/foo_bar_vX/foobar ie i have a pic in the foobar folder call dsc.1 id like to change it to foobar_dsc.0001 (2 Replies)
Discussion started by: thehive
2 Replies

4. Shell Programming and Scripting

Help needed in formatting script files

Hi, Can anyone tell me how i can convert all tab spaces inside a script to 4 spaces through another script. Also i need to find if all the quotes are matching and ended properly. Any idea whould be of great help. Many thanks! (3 Replies)
Discussion started by: justchill
3 Replies

5. Shell Programming and Scripting

Reading files under a folder and formatting content of each file

I have 'n' number of files in a folder .each file in the folder "myfolder" is having the content like. COLNAME ------------ AAAAAA BBBBBB CCCCCC DDDDDD ... ... ... ZZZZZZ 26 recrod(s) selected. My request is by reading each file in "myfolder" and format each file such a way... (18 Replies)
Discussion started by: rocking77
18 Replies

6. UNIX for Dummies Questions & Answers

SQL PLUS report formatting

Hi I am fetcthing the data from the oracle database using SQLPLUS. Here is my script #!/bin/ksh echo `sqlplus -s <<EOF set feedback off set linesize 5000 set pages 0 set space 0 set echo off set trimspool on set colsep '|' SELECT col1 , col2... (4 Replies)
Discussion started by: max_hammer
4 Replies

7. Shell Programming and Scripting

Formatting a report using awk

Our vendor produces a report that I would like to format in a particular way. Here is the sample output from their report: # AA.INDEX 2 11 2 239 52 (7,2) 07 MAY 11 203.1 55 # ACCOUNT 2 89561 2 ... (4 Replies)
Discussion started by: thaller
4 Replies

8. Shell Programming and Scripting

Formatting Report and Reading data and fetching the details from contents file

Data I was trying to write shell script which will be return the output in the below format First i was trying to do these using sed. sed -n '/.ksh/p' mainksh.ksh sed -e 's/*\(.*\)/\1/g' mainksh.ksh $RUN_DIR, $SUB_DIR and the variables which will be defined in the profile file. when i am... (0 Replies)
Discussion started by: rameshds
0 Replies

9. Shell Programming and Scripting

search for content in files. Name of files is in another file. Format as report.

Hi I have multiple files in a folder and one file which contains a list of files (one on each line). I was to search for a string only within these files and not the whole folder. I need the output to be in the form File1<tab>string instance 2<tab> string instance 2<tab>string instance 3... (6 Replies)
Discussion started by: pkabali
6 Replies

10. Shell Programming and Scripting

Formatting The Output Files & Matching Keys

I have the following 2 output files, one contain the standard output after i decrypt the encrypted file and another keys listed from the gpg trust db, Provider File: gpg: encrypted with 2048-bit RSA key, ID 96301328, created 2014-04-29 "JKL <400@abc.com>" gpg: encrypted with 2048-bit... (2 Replies)
Discussion started by: Ariean
2 Replies
BALANCE(1)						      General Commands Manual							BALANCE(1)

NAME
balance 3.42 - A simple TCP proxy with load balancing and failover mechanisms. SYNOPSIS
balance [ -b addr ] [ -B addr ] [ -t sec ] [ -T sec ] [ -adfpHM ] port host1[:port1[:maxc]] [!|%] [ ... hostn[:portn[:maxc]]] balance [ -b addr ] -i [ -d ] [ -M ] port balance [ -b addr ] -c cmd [ -d ] [ -M ] port DESCRIPTION
Balance is a simple, generic "userland" TCP proxy, which allows simple round-robin load balancing and graceful failover between several destination servers. Balance supports IPv6 on the listening side which makes it a very useful tool for IPv6 migration of IPv4 only services and servers. Balance is available at http://balance.sourceforge.net. Definitions: A possible destination consisting of a host address and a port is called a "channel". A channel is member of a "channel group". Channels are numbered in a group starting with 0. Groups are numbered starting with 0, which is the initial default group. Balance accepts connections on the given port and forwards them to the supplied channels. At least one channel (in the default group) must be specified. If there are two or more channels specified in a group balance performs a simple round-robin load balancing between the channels. Balance allows the definition of further channel groups. The connection scheme works as follows: balance tries first to establish a connec- tion to a channel in the first group (0), performing the standard round-robin load balancing scheme. If no channel in this group is avail- able, balance proceeds with the next higher channel group. Groups are simply separated with a "!" at the command line at startup and can be controlled interactively with the "group" command. A "%" instead of a "!" as a group separator declares the previous group to be of type "hash". This means that instead of a round-robin algorithm, a hash distribution based on the client ip address is used to determine the destination channel. This allows connecting one client always to the same server (e.g. balancing http sessions to a single server). Hosts may be specified either by hostname or by IP address. Ports may be specified either by name (as listed in /etc/services) or numeri- cally. If no port is specified in a destination, the destination port defaults to the source port that balance controls. Balance allows the specification of the maximum number of connections per channel. This parameter can be optionally added after the port specification separated by a colon (":"). If a maximum number of connections is specified a channel will only be used for this maximum num- ber of simultaneous connections. A maxc value of 0 denotes an unlimited number of connections. This is the initial default value of a chan- nel. The maximum number of groups and channels balance can handle is specified at compile time and is initially 16 channels in 16 groups. Failover to another destination (a "channel") occurs if the connection is refused on the current channel or if the connect timeout is reached trying to establish a connection. If all possible destinations (channels) currently fail, the client connection to balance is closed. Balance accepts the following options: a Enable autodisable option: A channel needs to be manually re-enabled after a failure. b Bindhost: Balance binds to the specified host (or address) for listen() instead to INADDR_ANY. B Bindhost: Balance binds to the specified host (or address) for outgoing connections (the connection will be initiated from this address). c Command: allows to send a command to the balance master process (see interactive mode) d Debug: Balance outputs debugging and tracing information messages on stderr. H Hashfailover: Balance does failover to next node even if hash is used. F Foreground: tells balance to stay in foreground. This might be useful for testing and debugging since balance can be stopped in that mode using ^C (or other interrupt character). M Use memory mapping for IPC instead of shared memory i Interactive Control: Balance connects to the running instance defined by local port and bind address via shared memory and allows to control the behaviour of it using a command line interface. The access permission using this interface are determined by the access restrictions of the shared memory segment in effect. help or ? prints out a short command overview, create allows to establish a new destination definition (channel) consisting of host and port in the current group, disable disables a channel in the current group, enable enables a channel again in the current group, group changes the current group in interactive mode where all following commands are targeted, hash changes the current group to be of type "Hash", help prints out online help informations, kill shuts down the master process and exits interactive mode, maxc <channel> <maxc> sets the maximum number of connection ot the channel (0 means infinite), mrtg-bytes <group> <channel> prints out the bytes received/sent in MRTG compatible format (intended to be called with -c automatically by MRTG), mrtg-conns <group> <channel> prints out the total connections in MRTG compatible format (intended to be called with -c automatically by MRTG), quit exits the interactive mode, reset resets the byte counters of a channel, rr changes the current group to be of type "Round Robin", show shows an overview and the status of all channels including the incoming and out- going transfer volume in bytes. The output is sorted by groups. Additionally the current connections (c) and the maximum allowed connections (maxc) are printed, version prints out the version and MAXGROUPS and MAXCHANNELS constants at compile time. p Packetdump: Balance shows all incoming and outgoing data on stdout using a simple always readable external representation of data. This might be useful for debugging and protocol analysis. t Connect Timeout: the default timeout trying to establish a connection to any destination can be changed using this option. The default timeout after which a destination is regarded to be currently inaccessible is 5 seconds. T Select Timeout: Timeout for select(), default = 0 (never). This feature is currently untested. EXAMPLES
$ balance smtp host1.test.net host2.test.net Connection to the local SMTP port will be forwarded alterating to the SMTP port on host1 and host2. Balance runs automatically in background. $ balance -b 2001:DB8::1 80 10.1.1.1 10.1.1.2 Balance binds on port 80 of the local IPv6 IP address 2001:DB8::1 and distributes connections to the IPv4 addresses 10.1.1.1 and 10.1.1.2. $ balance -fp imap mailserver Connections to the local IMAP port will always be forwarded to the host "mailserver". Balance stays in foreground and all data is printed in readable format on stdout. $ balance -f 8888 host1 10.1.1.1:8000 Connections to the local port 8888 are forwarded alternating to host1, port 8888 and the host 10.1.1.1, port 8000. Balance stays in foreground connected to the "controlling tty". $ balance imap mailserver1::16 ! mailserver2 Two groups are specified, each containing one channel member. First up to 16 simultaneous connections are forwarded to "mailserver1". As soon as they are consumed, balance proceeds with the next group (1) which will consume all remaining connections forwarding them to the imap ort on "mailserver2". $ balance pop3 host1 host2 host3 ! failover1 Balance does round robin load balancing for the three hosts in the default group 0 for pop3 services. If all three hosts in group 0 fail, all connections are then forwarded to the host "failover1". $ balance telnet target.munich.net::1 Here balance is used to restrict all connections to exactly one at a time forwarding the telnet port. $ balance 8888 localhost::12 ! localhost::4 ! localhost::2 localhost::2 ! localhost:25 This is a simple test, forming 5 groups where balance is self referencing its own services 20 times. This is simply a test which definitely can be tried at home. BUGS
In case that balance is not able to forward the connection to any destination the inital connection to balance is always first accepted and then closed again immediately. This is not in every case the behaviour that would have been seen directly on the destination host. AUTHOR
Thomas Obermair, Inlab Software GmbH (obermair@acm.org) Copyright (c) 2000-2007,2008 by Thomas Obermair (obermair@acm.org) and Inlab Software GmbH (http://www.inlab.de), Gruenwald, Germany. All rights reserved. Balance is released under the GNU GENERAL PUBLIC LICENSE, see the file COPYING in the source code distribution. 2008/04/08 BALANCE(1)
All times are GMT -4. The time now is 02:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy