Consolidate 2 file in 1 file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Consolidate 2 file in 1 file
# 8  
Old 12-24-2012
Try this:
Code:
 sort file10 > f1

Code:
 sort file11 > f2

Code:
 join f1 f2

Code:
Getting output :
2017917R 176606549.79 1766065498N
2068764R 295968115.42 2959681154N
2515401R 420124600.33 4201246003N
3514668R 277370594.03 2773705940N
7014281R 476346209.48 4763462094N
8017167R 139247928.99 1392479289N
8017172R 106126673.58 1061266735N

# 9  
Old 12-25-2012
Thank It did work

---------- Post updated at 02:12 PM ---------- Previous update was at 02:01 PM ----------

One more help
while loop is executing but I am not getting complete data in file
what I am getting is a single row instead of 9
Code:
#! bin/ksh

cat file12 | awk '{print $1}' >> FNN.txt
while read line
do
a=`grep $line file12 | awk '{print $3}' | cut -c 1-8`
b=`grep $line file12 | awk '{print $3}' | cut -c 9-10`
c=`echo "$a.$b"`

d=`grep $line file12 | awk '{print $2}'`
e=`echo $d - $c|bc`
echo "FNN,Actual Charges,Sent Charges,Remaining Charges" > check.txt
echo "$line,$d,$c,$e" >> check.txt
done<FNN.txt

output
Code:
pin@ssdb0220[mir]$ cat check.txt
FNN,Actual Charges,Sent Charges,Remaining Charges
8017172R,106126673.58,10612667.35,95514006.23

In FNN.txt I have below data
Code:

File12 has below data
[code]


expected output
Code:
.
.
.
.
.9 FNN mentioned in fNN.txt

---------- Post updated at 02:30 PM ---------- Previous update was at 02:12 PM ----------

find out result
echo statement to be mentioned outside the loop

Code:
echo "FNN,Actual Charges,Sent Charges,Remaining Charges" > check.txt
cat file12 | awk '{print $1}' >> FNN.txt
while read line
do
a=`grep $line file12 | awk '{print $3}' | cut -c 1-8`
b=`grep $line file12 | awk '{print $3}' | cut -c 9-10`
c=`echo "$a.$b"`

d=`grep $line file12 | awk '{print $2}'`
e=`echo $d - $c|bc`
echo "$line,$d,$c,$e" >> check.txt
done<FNN.txt

---------- Post updated at 08:57 PM ---------- Previous update was at 02:30 PM ----------

Thanks lot for your help every one

Last edited by mirwasim; 02-06-2013 at 11:29 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Consolidate files based on priority

please help, I would like to merge 4 files, all of them same format. The first col is the key for all files,followed by variable number of fields so I want to check if the key is present in the files according to priority and then also add a column saying it came from which file . So the... (4 Replies)
Discussion started by: ritakadm
4 Replies

2. Shell Programming and Scripting

Consolidate several lines of a CSV file with firewall rules, in order to parse them easier?

Consolidate several lines of a CSV file with firewall rules Hi guys. I have a CSV file, which I created using an HTML export from a Check Point firewall policy. Each rule is represented as several lines, in some cases. That occurs when a rule has several address sources, destinations or... (4 Replies)
Discussion started by: starriol
4 Replies

3. Shell Programming and Scripting

Multiple lines consolidate

This post is start for me ... I stumped at something that I not sure as to how start on ... I tried so of your script that i honestly lost mind looking and looking here ... please help COL1 COl2 COL3 12222 AUH FLUEH 12222 SSC OPERA 12222 SSC ... (8 Replies)
Discussion started by: Sebastian.Thoma
8 Replies

4. Shell Programming and Scripting

Script to consolidate files as mails,groupid

Hi, I'm newbie in Bash scripting. Here is scenario I've a file which containslist of 100 mailgroup and in a directory i have 100 files with each group's respective mail addresses. I'd like to make one CSV file with this information as follows. consolidated files with mailid,groupname. ... (7 Replies)
Discussion started by: manish123456
7 Replies

5. Shell Programming and Scripting

Extract two file contents and consolidate in the third file

Hi all I have two files (first_file.txt) and ( second_file.txt). The first file consists of sentences line by line given as : Established in 1905 , Las Vegas officially became a city in 1911 . With the growth that followed , at the close of the century Las Vegas was the most populous... (10 Replies)
Discussion started by: my_Perl
10 Replies

6. Shell Programming and Scripting

How to consolidate values in one column from different rows into one?

Hi Guys, Thank you all for helping me with my different queries and I continue to get better at scripting because of help from all of you! I have a file that would look something like - ID SUB ID VALUE 1 10 5 2 18 7 1 ... (1 Reply)
Discussion started by: sncoupons
1 Replies

7. Shell Programming and Scripting

consolidate file in unix

hi, i am trying to consolodate the files in the unix with the '>>' i have some 50 or 60 files.is there any another way of consolidating the alll 50 or 60 files in to one file. actually the way i m doing creaating the problem while loading the file with teradat tpump and fasload. so if there is... (3 Replies)
Discussion started by: narang.mohit
3 Replies
Login or Register to Ask a Question