Sponsored Content
Full Discussion: awk command - column merging
Top Forums Shell Programming and Scripting awk command - column merging Post 302449288 by shashi792 on Monday 30th of August 2010 05:03:59 AM
Old 08-30-2010
Question awk command - column merging

I have two files having 3 coulms and 1 column respectively
Code:
file1.txt
0    22.89    35.60
10    22.80    35.61
20    22.70    35.63
30    22.32    35.68
50    19.23    35.79
75    16.10    35.59
100    15.00    35.52
125    14.45    35.46
150    13.91    35.41
200    12.94    35.28

Code:
file 2
1575.15
1574.68
1574.16
1571.7
1550.89
1530.54
1523.9
1520.79
1517.8
1512.52
1506.69
1500.99
1491.52

required : I want to merge column 1 from file1 with coumn 1 of file2 >> new file. but in file 2 i have more rows than required.

In my new file i want equal number of rows as in file 1
(no of rows in file 1 varies everytime)
Code:
output file
0      1575.15
10    1574.68
20    1574.16
30    1571.7
50    1550.89
75    1530.54
100  1523.9
125  1520.79
150  1517.8
200  1512.52

No of rows should always be equal to number of rows in file 1 (file 2 will always have more rows than required)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merging column files

Hi,Iam new to Unix.I have a file FileA which is a variable length file where each column is seperated by delimitter "|". FileA: SrNo Name Address 1-234|name1|Addr1 1-34|name2|Addr2 1-2345|name3|Addr3 FileB: SrNo Address 1-34<<06 SPACES>>Addr1<<8 spaces>> 1-234<<05... (1 Reply)
Discussion started by: swapna321
1 Replies

2. Shell Programming and Scripting

Extracting a column from a file and merging with other file using awk

Hi All: I have following files: File 1: <header> text... text .. text .. text .. <\header> x y z ... File 2: <header> text... text .. text .. (4 Replies)
Discussion started by: mrn006
4 Replies

3. UNIX for Dummies Questions & Answers

Merging Tables by a column

Dear Friends, I really do not know Linux and I really would like to understand it because it does help to work with large data. I am reading this forum for 1 week to try a solution for my problem. I think that, using others post informations, I was almost there... I have 2 big tables... (4 Replies)
Discussion started by: lColli
4 Replies

4. Shell Programming and Scripting

awk command : row by row merging of two files

I want to write a scrpit to merge files row wise (actually concatinating) main.txt X Y Z file 1 A B C file 2 1 2 3 now i want the script to check if the file1 is empty or not, if empty then make it like A B C 1 2 3 again to check if second file is empty if not do as done... (0 Replies)
Discussion started by: shashi792
0 Replies

5. Shell Programming and Scripting

merging two files based on first column

I had two files file1 and file2. I want a o/p file(file3) like below using first column as ref. Pls give suggestion ass join is not working as the number of lines in each file is nealry 5 C? file1 --------------------- 404000324810001 Y 404000324810004 N 404000324810008 Y 404000324810009 N... (1 Reply)
Discussion started by: p_sai_ias
1 Replies

6. UNIX for Dummies Questions & Answers

Merging two text files by a column

So I have two text files. The first one looks like this: refsnp_id chr_name chrom_start 1 rs1000000 12 126890980 2 rs10000010 4 21618674 3 rs10000012 4 1357325 4 rs10000013 4 37225069 5 rs1000002 3 183635768 And the second one looks like this: AUC rs1000000 0.03 0.1240 AUC ... (4 Replies)
Discussion started by: evelibertine
4 Replies

7. Shell Programming and Scripting

Merging rows with same column 1 value

I have the following space-delimited input: 1 11.785710 117.857100 1 15 150 1 20 200 1 25 250 3 2.142855 21.428550 3 25 250 22 1.071435 10.714350 The first field is the ID number, the second field is the percentage of the total points that the person has and the third column is the number... (3 Replies)
Discussion started by: mdlloyd7
3 Replies

8. Shell Programming and Scripting

awk command to print only selected rows in a particular column specified by column name

Dear All, I have a data file input.csv like below. (Only five column shown here for example.) Data1,StepNo,Data2,Data3,Data4 2,1,3,4,5 3,1,5,6,7 3,2,4,5,6 5,3,5,5,6 From this I want the below output Data1,StepNo,Data2,Data3,Data4 2,1,3,4,5 3,1,5,6,7 where the second column... (4 Replies)
Discussion started by: ks_reddy
4 Replies

9. Shell Programming and Scripting

Merging middle column in a file

I want to merge files as described below: File 1 a;1;abc b;2;def c;3;xyz d;4;pqr e;5;mno File 2 b;41 d;77 output a;1;abc (9 Replies)
Discussion started by: Prabal Ghura
9 Replies

10. UNIX for Beginners Questions & Answers

Merging rows based on same ID in First column.

Hellow, I have a tab-delimited file with 3 columns : BINPACKER.13259.1.p2 SSF48239 BINPACKER.13259.1.p2 PF13243 BINPACKER.13259.1.p2 G3DSA:1.50.10.20 BINPACKER.13259.2.p2 SSF48239 BINPACKER.13259.2.p2 PF13243 BINPACKER.13259.2.p2 G3DSA:1.50.10.20... (7 Replies)
Discussion started by: anjaliANJALI
7 Replies
XkbAllocGeomOverlayRows(3)					   XKB FUNCTIONS					XkbAllocGeomOverlayRows(3)

NAME
XkbAllocGeomOverlayRows - Allocate rows in a overlay SYNOPSIS
Status XkbAllocGeomOverlayRows (XkbOverlayPtr overlay, int num_needed); ARGUMENTS
- overlay section for which rows should be allocated - num_needed number of new rows required DESCRIPTION
Xkb provides a number of functions to allocate and free subcomponents of a keyboard geometry. Use these functions to create or modify key- board geometries. Note that these functions merely allocate space for the new element(s), and it is up to you to fill in the values explicitly in your code. These allocation functions increase sz_* but never touch num_* (unless there is an allocation failure, in which case they reset both sz_* and num_* to zero). These functions return Success if they succeed, BadAlloc if they are not able to allocate space, or BadValue if a parameter is not as expected. XkbAllocGeomOverlayRows allocates num_needed rows and adds them to the overlay. No initialization of the rows is done. To free rows in an overlay, use XkbFreeGeomOverlayRows. DIAGNOSTICS
BadAlloc Unable to allocate storage BadValue An argument is out of range SEE ALSO
XkbFreeGeomOverlayRows(3) X Version 11 libX11 1.3.2 XkbAllocGeomOverlayRows(3)
All times are GMT -4. The time now is 12:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy