Collecting header from another file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Collecting header from another file
# 1  
Old 12-31-2013
Collecting header from another file

I want to add header description from a file by matching the 2nd col of another file. .

The lookup file is at

ftp://ftp.ncbi.nlm.nih.gov/pub/COG/KOG/kog

The table file looks like

Code:
comp1001565_c0_seq1     At1g14590       48.48   66      34      0       200     3       171     236     2e-16   82.8
comp10017_c0_seq1       Hs20533698      34.52   84      55      1       15      266     58      139     1e-07   53.1

So the two rows have 2nd cols as At1g14590 and Hs20533698.

At1g14590 is not found in the lookup file but Hs20533698 is classified under
[U] KOG0811 SNARE protein PEP12/VAM3/Syntaxin 7/Syntaxin 17 in
the lookup file.

desired output

Code:
comp1001565_c0_seq1     At1g14590       48.48   66      34      0       200     3       171     236     2e-16   82.8
comp10017_c0_seq1       Hs20533698      34.52   84      55      1       15      266     58      139     1e-07   53.1     [U] KOG0811 SNARE protein PEP12/VAM3/Syntaxin 7/Syntaxin 17

# 2  
Old 12-31-2013
Try :

Code:
$ awk 'FNR==NR{if(/^\[/){h=$0;next}A[$2]=h;next}($2 in A){$0 = $0 OFS A[$2]}1' lookupfile table

This User Gave Thanks to Akshay Hegde For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies

2. Shell Programming and Scripting

Manipulate all rows except header, but header should be output as well

Hello There... I have a sample input file .. number:department:amount 125:Market:125.23 126:Hardware store:434.95 127:Video store:7.45 128:Book store:14.32 129:Gasolline:16.10 I will be doing some manipulations on all the records except the header, but the header should always be... (2 Replies)
Discussion started by: juzz4fun
2 Replies

3. UNIX for Dummies Questions & Answers

Merge all csv files in one folder considering only 1 header row and ignoring header of all others

Friends, I need help with the following in UNIX. Merge all csv files in one folder considering only 1 header row and ignoring header of all other files. FYI - All files are in same format and contains same headers. Thank you (4 Replies)
Discussion started by: Shiny_Roy
4 Replies

4. Shell Programming and Scripting

Comparing one file header with another file header

Hi Experts, In our project we have requirement where in we have to compare header of one file with header in the parameter file. There are 20 files which we ftp from one site. All this files have different header. We are comapring this file with our parameter file(which is having the header... (2 Replies)
Discussion started by: Amey Joshi
2 Replies

5. Shell Programming and Scripting

Collecting details

Hi all, I am having lots of oracle servers. I want to collect some health check details from all the server and report to one single centralized server. What would be best solution for this? OS: AIX Thanks Gopal (1 Reply)
Discussion started by: ilugopal
1 Replies

6. Shell Programming and Scripting

Renaming all header to specific header pattern

Input #HAC0253 EFVHIJHIJEFVTHIJOPKOPKTEFVEFVEFVOPKHIJOPKOPKHIJTTEFVEFVTEFV #BASFS12 EFVEFVHIJEFVEFVTOPKEFVOPKTHIJTTHIJOPK #ACG5115 TEFVEFVOIJEFVHIJHIJOPKOPKHIJHIJTTEFVEFVOPKTTEFVEFVOPKHIJOPKOPKOPK #ECG5114 IJTOPKHIJEFVOEFVEFVOPKTTEFVEFVOPKHIJOPKOPKOPK . . Output (5 Replies)
Discussion started by: patrick87
5 Replies

7. Shell Programming and Scripting

Collecting specific portion from a file

I have a file which contains data like a b x col1:data1 formula:data3 this is for 2 a c col1:@bkw formula:dontad ad asd as per a \ i want the data from col1 and formula to keep the col1 data in left side of excel and col2 data in right side of it (1 Reply)
Discussion started by: bmrout007
1 Replies

8. Linux

Reading the header of a tar file(posix header)

say i have these many file in a directory named exam. 1)/exam/newfolder/link.txt. 2)/exam/newfolder1/ and i create a tar say exam.tar well the problem is, when i read the tar file i dont find any metadata about the directories,as you cannot create a tar containig empty directories. on the... (2 Replies)
Discussion started by: Tanvirk
2 Replies

9. Shell Programming and Scripting

Need Help: Collecting similar messages in a file

Hi All, Since i am very new to shell scripting, i need help from you guys. Suppose there is a file containing: Log message: Ashish "asasasa" asasa asasa asasas.info1 Log message: Kapil "asasasa" asasa asasa asasas..info1 (2 Replies)
Discussion started by: ashish.kapil
2 Replies

10. UNIX for Dummies Questions & Answers

Collecting data from TOP to a file

Is there a way to collect data from top command to a file at regular intervals. I need this on HP-UX. I need to gather resident memory usage. I know that sar will give %cpu usage. There is a pmap command which gives memory usage in solaris. Is there a similar command in HP-UX Thanks (5 Replies)
Discussion started by: sssow
5 Replies
Login or Register to Ask a Question