Sponsored Content
Top Forums Shell Programming and Scripting AWK - phone bill with several files Post 302524380 by Godie on Monday 23rd of May 2011 07:30:11 AM
Old 05-23-2011
Java AWK - phone bill with several files

First of all I want apologize for my English.Smilie
I have this problem, I would like to make a phone bill, the first file has Phone number, seconds of the call and call destination, and the second file has the prices for each destination call, and would like to have a third file where it calculate all.

Example:

(Phone number) (seconds of the call) (call destination)


file1.txt
666666661 158 ENG
666666662 175 AUS
666666663 357 PAR
666666664 741 MAD
666666665 624 MOS
666666661 847 MAD
666666662 147 AUS
666666662 582 PAR

-------------------------------------------------
(destination) (price)

file2.txt
ENG 0.02
AUS 0.12
PAR 0.03
MAD 0.06
MOS 0.21

--------------------------------------------
file3.txt
666666661 53.98
666666662 56.1
666666663 10.71
666666664 44.46
666666665 131.04


---------------------------------------
I'm tring this, but I only get one record per file. Smilie

Code:
#!/bin/bash

awk  '
BEGIN {


{while ( getline < "file1.txt" )
            {
        i++       
        f1[i] = $1
          }
      }

{while ( getline < "file2.txt" )
            {    
        x++       
        f2[x] = $1
          }
      }

}


{print [NR], [NR] }' file3.txt

---------------------------------------

I would appreciate any help.

Last edited by Godie; 05-23-2011 at 09:10 AM..
 

We Also Found This Discussion For You

1. Solaris

Solaris View/Transfer Files Android Phone

I'm trying to sync/transfer files from my UNIX box and Android Phone and vice versa. I know that Android Phones show up seamlessly (mostly) in Linux given their incestuous relationship. Is there a way to do it in UNIX or more specifically in Solaris 11.3 (i86)?:confused: I haven't found one... (2 Replies)
Discussion started by: Nostradamus1973
2 Replies
All times are GMT -4. The time now is 04:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy