Find out the match data content?!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find out the match data content?!
# 8  
Old 11-04-2009
yup. you're right.
Thanks a lot ^^
By using the join, do you got any idea like how to let the output result got tab delimiter in between each line?
I got try to do this by using the awk "\t" for the file3
Code:
awk '{print $1"\t",$2"\t",$3"\t"}' file3 > file4

Instead of using awk to generate file4.
Do you have any other suggestion to improve my code by just using join to do it?
Thanks for your suggestion Smilie

Last edited by Franklin52; 11-04-2009 at 09:18 AM.. Reason: Correcting code tags
# 9  
Old 11-04-2009
try this
Code:
cat file3 | tr "\n" "\t" > file4

or more direct
Code:
join FILE1.dat FILE2.dat | tr "\n" "\t" > file4


Last edited by frans; 11-04-2009 at 05:20 AM.. Reason: more direct
# 10  
Old 11-04-2009
Hi,
I just try both of the code that you suggested.
End up It will link all the data together and generated the output like this:
1285_t chris germany 8288_c steve england 9626_a dave swiss
Do I did anything wrong?
Thanks again, frans Smilie
# 11  
Old 11-04-2009
Quote:
Originally Posted by patrick87
Hi,
I just try both of the code that you suggested.
End up It will link all the data together and generated the output like this:
1285_t chris germany 8288_c steve england 9626_a dave swiss
Do I did anything wrong?
Thanks again, frans Smilie
You did allright Smilie
I think your awk script looks good. I couldn't do better
# 12  
Old 11-04-2009
Never mind.
Knowledge is sharing ^^
# 13  
Old 11-04-2009
Something like this :

Code:
awk 'NR==FNR{a[$1]=$1;next} { if($1 in a) print }' f1 f2

Not sure of the performance your expecting can be reached or not.
# 14  
Old 11-04-2009
If it is too slow, you could test if awk runs faster. Especially mawk is lightning quick.
Code:
awk 'NR==FNR{a[$1]=1;next}a[$1]' file1 file2>file3



---------- Post updated at 03:37 AM ---------- Previous update was at 03:35 AM ----------

Oops somehow missed panyam's answer. Oh well..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Data match 2 files based on first 2 columns matching only and join if match

Hi, i have 2 files , the data i need to match is in masterfile and i need to pull out column 3 from master if column 1 and 2 match and output entire row to new file I have tried with join and awk and i keep getting blank outputs or same file is there an easier way than what i am... (4 Replies)
Discussion started by: axis88
4 Replies

2. Shell Programming and Scripting

awk command to get file content until 2 occurrence of pattern match

AWK command to get file content until 3 occurrence of pattern match, INPUT FILE: JMS_BODY_FIELD:JMSText = <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <custOptIn xmlns="http://com/walm/ta/cu/ccs/xml2"> <person>Romi</person> <appName>SAP</appName> </custOptIn> ... (4 Replies)
Discussion started by: prince1987
4 Replies

3. Shell Programming and Scripting

Sorting content between match pattern and move on with awk and sed

S 0.0 0.0 (reg, inst050) k e f d c S 0.0 0.0 (mux, m030) k g r s x v S 0.0 0.0 (reg, inst020) q s n m (12 Replies)
Discussion started by: ctphua
12 Replies

4. Shell Programming and Scripting

Program to match the id and replace one letter in the content

Hi all, I have one file with a sequence and the other file which says the position and the letter to be changed. I have to match two files and replace content. Example is shown which will describe what I want to do. For example, file 1 has many sequences and few are shown below sequence file:... (6 Replies)
Discussion started by: kaav06
6 Replies

5. Shell Programming and Scripting

Column content match and add suffix

My input chr3 galGal3_xenoRefFlat CDS 4178235 4178264 0.000000 + 0 gene_id "T6J4.19; T6J4_19"; transcript_id "T6J4.19; T6J4_19"; chr3 galGal3_xenoRefFlat exon 4178235 4178264 0.000000 + . gene_id "T6J4.19; T6J4_19"; transcript_id "T6J4.19;... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

6. Shell Programming and Scripting

Extract all content that match exactly only specific word

Input: 21 templeta parent 35718 36554 . - . ID=parent_cluster_50.21.11; Name=Partial%20parent%20for%20training%20set; 21 templeta kids 35718 36554 . - . ID=_52; Parent=parent_cluster_5085.21.11; 21 templeta ... (7 Replies)
Discussion started by: patrick87
7 Replies

7. Shell Programming and Scripting

Extract specific data content from a long list of data

My input: Data name: ABC001 Data length: 1000 Detail info Data Direction Start_time End_time Length 1 forward 10 100 90 1 forward 15 200 185 2 reverse 50 500 450 Data name: XFG110 Data length: 100 Detail info Data Direction Start_time End_time Length 1 forward 50 100 50 ... (11 Replies)
Discussion started by: patrick87
11 Replies

8. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

9. Shell Programming and Scripting

How to find first match and last match in a file

Hi All, I have a below file: ================== 02:53 pravin-root 02:53 pravin-root 03:05 pravin-root 02:55 pravin1-root 02:59 pravin1-root ================== How do I find the first and last value of column 1. For example, how do I find 02:53 is the first time stamp and 03:05 is... (3 Replies)
Discussion started by: praving5
3 Replies

10. UNIX for Dummies Questions & Answers

X11 auth data does not match fake data

We have different unix servers, let say I have server 1 and server 2. Well whenever I ssh from server 1 to server 2, I'm ok, but when I ssh from server 2 to server 1, I can connect just fine, but I get this message: X11 auth data does not match fake data X11 auth data does not match fake data... (1 Reply)
Discussion started by: samytrix
1 Replies
Login or Register to Ask a Question