merging colums from different files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting merging colums from different files
# 1  
Old 01-24-2005
merging colums from different files

hi all ,

i have three files that contain numbes as the first column .
i want to add these files together so the numbers from the first file is in the first column ; the numbers from the second file in the second column; and the numbers from the third file in the third column .


as an example :

file1 file2 file3
12 23 236
13 234 234
134 233 234
14 237 233
14 2367 232
14 2399 232



file 4
12 23 236
13 234 234
134 233 234
14 237 233
14 2367 332
14 2399 232

thank in advance
# 2  
Old 01-24-2005
This sounds like it could be a homework problem. If it is, please read the rules. If it isn't, please let us know what you've tried so far, and what specific problem you're having.

Thanks,
ZB
# 3  
Old 06-15-2006
MySQL Useful help

Sorry friends,

Even Im also trying for the same things,

Actually I have 4 report files each contains Jobs name, order date, run date and status. I have to generate one resultant report which looks to be:


job name Order date run date status

I've tried to select each column values into seperate variables and used echo.

echo "$var1\t" >> result.report
echo"$var2\t" >> result.report
echo "$var3\t" >> result.report
echo "$var4\n" >> result.report


It is working well but I want to know are there any ways to achieve this?

Your help will be appreciated.

Many Thanks and Regards.

Smilie Love
# 4  
Old 06-16-2006
have u tried using paste command
paste f1 f2
# 5  
Old 06-16-2006
hey raom,

thanks for introducing 'paste'. its new for me.

regards
prajit
# 6  
Old 06-19-2006
Hi,

Try this way...

Let us say, your data is in file1 file2 file3 and file4.

--------------------------------------------------------------------------
#!/bin/ksh

rm a1 b1 c1 d1

cat file1 | while read record
do
echo $record | cut -d" " -f1 >> a1
done

cat file2 | while read record
do
echo $record | cut -d" " -f1 >> b1
done

cat file3 | while read record
do
echo $record | cut -d" " -f1 >> c1
done

cat file4 | while read record
do
echo $record | cut -d" " -f1 >> d1
done

paste a1 b1 c1 d1
--------------------------------------------------------------------------

Best Regards,
Sridhar M

Quote:
Originally Posted by ppass
hi all ,

i have three files that contain numbes as the first column .
i want to add these files together so the numbers from the first file is in the first column ; the numbers from the second file in the second column; and the numbers from the third file in the third column .


as an example :

file1 file2 file3
12 23 236
13 234 234
134 233 234
14 237 233
14 2367 232
14 2399 232



file 4
12 23 236
13 234 234
134 233 234
14 237 233
14 2367 332
14 2399 232

thank in advance
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare 2 colums in two files

Hi , I am trying to write a part in shell script. I have two files with one column each and would like to output it to a new file giving the records which are different.Pls help experts. File1 Column name 11 12 13 14 18 File2 Column name 11 12 14 17 19 (2 Replies)
Discussion started by: Rossdba
2 Replies

2. Shell Programming and Scripting

Merging two files

Guys, I am having little problem with getting a daily report! The daily process that I do is as follows 1. Unload Header for the report from the systables to one unl file, say Header.unl 2. Unload the data from the required table/tables to another unl file, say Data.unl 3. Send a... (2 Replies)
Discussion started by: PikK45
2 Replies

3. Shell Programming and Scripting

Merging two files with same name

Hello all, I have limited experience in shell scripting. Here goes my question: I have two directories that have same number of files with same file names i.e. consider 2 directories A and B. Both directories have files 1.txt, 2.txt...... I need to merge the file 1.txt of A with file 1.txt... (5 Replies)
Discussion started by: jaysean
5 Replies

4. UNIX for Dummies Questions & Answers

Merging two files

Hi, I have two files a.txt and b.txt. a.txt 1 2 3 4 b.txt a b c d e I want to generate a file c.txt by merging these two file and the resultant file would contain c.txt 1 (4 Replies)
Discussion started by: siba.s.nayak
4 Replies

5. Shell Programming and Scripting

merging of files.

Hi, I want to merge the two files on the basis of columns like... file 1 Data Key A 12 B 13 file2 Data Value A A1 A A2 B B1 B B2 (5 Replies)
Discussion started by: clx
5 Replies

6. Shell Programming and Scripting

Compare two csv files by two colums and create third file combining data from them.

I've got two large csv text table files with different number of columns each. I have to compare them based on first two columns and create resulting file that would in case of matched first two columns include all values from first one and all values (except first two colums) from second one. I... (5 Replies)
Discussion started by: agb2008
5 Replies

7. Shell Programming and Scripting

Help with merging files

i would like to merge two files that have the same format but have different data. i would like to create one output file that contains information from both the original files.:rolleyes: (2 Replies)
Discussion started by: joe black
2 Replies

8. Shell Programming and Scripting

Merging 2 files

Hi, I have got two files 1.txt 1111|apple| 2222|orange| 2.txt 1111|1234|000000000004356| 1111|1234|000000001111| 1111|1234|002000011112| 2222|5678|000000002222| 2222|9102|000000002222| I need to merge these two so that my out put looks like below: Search code being used should be... (4 Replies)
Discussion started by: jisha
4 Replies

9. Shell Programming and Scripting

merging two files

Friends, os: redhat enterprise linux/SCO UNIX5.0 I have two files and I would like to merge on given key value. Now I have tried with join commd but it does not supporte multiple delimiters. and if records length is not fixed. join -a1 5 -a2 1 -t -o file1 file2 > outname Can any... (7 Replies)
Discussion started by: vakharia Mahesh
7 Replies

10. UNIX for Dummies Questions & Answers

Merging two files

Hi I have a requirement like this. I have two files This is how data1.txt looks: EI3171280 38640658501 NENN2005-12-129999-12-312005-12-12HALL NANCY 344 CHENEY HIGHWAY ... (4 Replies)
Discussion started by: venommaker
4 Replies
Login or Register to Ask a Question