01-09-2009
39,
0
Join Date: Oct 2008
Last Activity: 27 March 2009, 5:45 PM EDT
Posts: 39
Thanks Given: 0
Thanked 0 Times in 0 Posts
Help with script
I have two files, how to open them and read files, then company two files, if the item in first file is the same name in second file, then add qty number in second file and attach the number to first file.
file1:
NAME DESCRIPTION WHSE BEGQTY ONHAND
-----------------------------------------------------------------
ABC ABC COMPANY CA 32 34
ACB ACB COMPANY CA 5 18
ERC ERC COMAPNAY TX 10 4
file2:
NAME DESCRIPTION WHSE TRXCD QTY
-------------------------------------------------------------------
ABC ABC COMPANY CA 1 10
ABC ABC COMPANY CA 1 3
ABC ABC COMPANY CA 4 -9
ABC ABC COMPANY CA 4 -5
ACB ACB COMPANY CA 1 8
ACB ACB COMPANY CA 1 10
ACB ACB COMPANY CA 4 -3
ACB ACB COMPANY CA 4 -5
ERC ERC COMPANY TX 1 11
ERC ERC COMPANY TX 4 -5
ERC ERC COMPANY TX 4 -10
the result should be:
NAME DESCRIPTION WHSE BEGQTY RECEVIED ADJUST SOLD ONHAND
-----------------------------------------------------------------------
ABC ABC COMPANY CA 32 13 -3 14 34
ACB ACB COMPANY CA 5 18 -3 8 18
ERC ERC COMPANY TX 10 11 2 15 4
Condition is:
if (file1 name = file2 name && file1 whse = file2 whse)
then
if(file2 trxcd = 1)
then
add qty number, get subtotal to recevied field
if(file2 trxcd = 4)
then
add qty number, get subtotal to sold field
adjust = begqty + received - sold - onhand
I write program using java language and can run under windows, but I want to know how to run it using shell script on Unix.