matching IDs from two files and editting


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers matching IDs from two files and editting
# 1  
Old 07-07-2009
matching IDs from two files and editting

I have two files. One has:

Code:
 
ID# 0 a b c d e f g h i j k....................~2 milion columns
ID# 0 l m n o p q r s t u v....................~2 milion columns
.
.
.
~6000 lines

Other has:

Code:
 
ID# 1
or 
ID# 2
.
.
~6000 lines

Where the ID# matches the two files together.

Basically the 1 or 2 that is present in the second column of the second file I want to paste into the first file (in the place of the 0 in the second column of that file). The IDs aren't in the same order in each file. Is there a way of getting that column into the first file?

Thanks in advance for your help.
# 2  
Old 07-07-2009
a bit of reading first: (yes manpages...)
man sort, paste, join...

a few solutions exists, but the files must be correctly sorted first...
# 3  
Old 07-08-2009
The problem is, the second file does not contain all of the entries in the first file. For those missing I want to leave the second column as zero.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

List of all ids,groups, privilege ids

I wish to pull out a list of all user ids on the system, including the privileged ids, the groups to which they belong to. Sometimes after deleting an id also, its home dir does not get deleted or an entry is left behind in /etc/passwd. Can someone help me with a script to achieve both. (2 Replies)
Discussion started by: ggayathri
2 Replies

2. UNIX for Beginners Questions & Answers

Match duplicate ids in two files

I have two text files. File 1 has 150 ids but all the ids exists in duplicates so it has 300 ids in total. File 2 has 1500 ids but all exists in duplicates so file 2 has 300 ids in total. i want to match the first occurance of every id in file 1 with first occurance of thet id in file 2 and 2nd... (2 Replies)
Discussion started by: limd
2 Replies

3. Shell Programming and Scripting

Find first n element by matching IDs

Hi All I have a problem that I am not able to resolve. Briefly, I have a file like this: ID_1 10 ID_2 15 ID_3 32 ID_4 45 ID_5 66 ID_6 79 ID_7 88This file is numerically ordered for the 2th column. And another file containing a list of IDs(just one in this example) ID_4What I... (7 Replies)
Discussion started by: giuliangiuseppe
7 Replies

4. Shell Programming and Scripting

Merging files with common IDs without JOIN

Hi, I am trying to merge information across 2 files. The first file is a "master" file, with all IDS. File 2 contains a subset of IDs of those in File 1. I would like to match up individuals in File 1 and File 2, and add information in File 2 to that of File 1 if they appear. However, if an... (3 Replies)
Discussion started by: hubleo
3 Replies

5. Shell Programming and Scripting

Editting a record

robert (6 Replies)
Discussion started by: robert89
6 Replies

6. UNIX for Dummies Questions & Answers

Extract columns by matching ids in two files

Hello, I want to extract columns from file2 to file3 by matching ids between file1 and file2. The extracted columns should be in same order as file1 ids. for example: file1.txt 1823 607 R2A9 802 771 file2.txt 1823 1 2 4 22 11 4 29 607 12 3 3 R2A9... (8 Replies)
Discussion started by: ryan9011
8 Replies

7. UNIX for Dummies Questions & Answers

Merge two files with common IDs but unequal number of rows

Hi, I have two files that I would like to merge and think that there should be a solution using awk. The files look something like this: file 1 IDX1 IDY1 IDX2 IDY2 IDX3 IDY3 file 2 IDY1 dataA data1 IDY2 dataB data2 IDY3 dataC data3 Desired output IDX1 IDY1 dataA data1 IDX2 ... (5 Replies)
Discussion started by: katie8856
5 Replies

8. UNIX for Dummies Questions & Answers

Match values/IDs from column and text files

Hello, I am trying to modify 2 files, to yield results in a 3rd file. File-1 is a 8-columned file, separted with tab. 1234:1 xyz1234 blah blah blah blah blah blah 1234:1 xyz1233 blah blah blah blah blah blah 1234:1 abc1234 blah blah blah blah blah blah n/a RRR0000 blah blah blah... (1 Reply)
Discussion started by: ad23
1 Replies

9. Shell Programming and Scripting

Editting each line in a file

Hi Can anyone please help me in resolving my issue. I have a file with entries like this t9787ms 99970 22/08/2010 12:30 /www.google.com t9788ms 99942 22/08/2010 12:40 /www.google.com t4788ms 88942 22/08/2010 01:40 /www.google.com there are around 5 lakh records of this type my requirement... (4 Replies)
Discussion started by: mskalyani
4 Replies

10. Shell Programming and Scripting

editting file

Hi, I am having sequence of process ids in one file. My file contents is (Output of fuser someobject.so). 654 14583 17890 25902 This no. of processes may vary depends up on the object. I want to check all the processes one by one. If i want to apply egrep, I need to... (3 Replies)
Discussion started by: sharif
3 Replies
Login or Register to Ask a Question