Sponsored Content
Top Forums UNIX for Dummies Questions & Answers if matching strings in file1 and file2, add column from file1 to file2 Post 302674467 by aster007 on Thursday 19th of July 2012 05:01:01 PM
Old 07-19-2012
Code:
cat file1 | awk '{print $1}' | while read NUM
do
        # echo ${NUM}

        grep "Gene_${NUM}" file2 2>/dev/null  # output to tty or suppress 

        RC=$?

        if [[ ${RC} == 0 ]]
        then
                REP_STR=`grep "${NUM}  " file1 | awk '{print $2}'`

                # echo ${REP_STR}

                cat file2 | sed "s/\"Gene_"${NUM}"\"/${REP_STR} \"Gene_"${NUM}"\"/g" > temp_file
             
                cp temp_file file2
        fi
done

This User Gave Thanks to aster007 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk/sed search lines in file1 matching columns in file2

Hi All, as you can see I'm pretty new to this board. :D I'm struggling around with small script to search a few fields in another file. Basically I have file1 looking like this: 15:38:28 sz:10001 pr:14.16 15:38:28 sz:10002 pr:18.41 15:38:29 sz:10003 pr:19.28 15:38:30 sz:10004... (1 Reply)
Discussion started by: floripoint
1 Replies

2. UNIX for Advanced & Expert Users

print contents of file2 for matching pattern in file1 - AWK

File1 row is same as column 2 in file 2. Also file 2 will either start with A, B or C. And 3rd column in file 2 is always F2. When column 2 of file 2 matches file1 column, print all those rows into a separate file. Here is an example. file 1: 100 103 104 108 file 2: ... (6 Replies)
Discussion started by: i.scientist
6 Replies

3. UNIX for Dummies Questions & Answers

Delete strings in file1 based on the list of strings in file2

Hello guys, should be a very easy questn for you: I need to delete strings in file1 based on the list of strings in file2. like file2: word1_word2_ word3_word5_ word3_word4_ word6_word7_ file1: word1_word2_otherwords..,word3_word5_others... (7 Replies)
Discussion started by: roussine
7 Replies

4. Shell Programming and Scripting

Match one column of file1 with that of file2

Hi, I have file1 like this aaa ggg ddd vvv eeeand file2 aaa 2 aaa 443 xxx 76 aaa 34 ggg 33 wee 99 ggg 33 ddd 1 ddd 10 ddd 98 sds 23 (4 Replies)
Discussion started by: polsum
4 Replies

5. Shell Programming and Scripting

Pattern Matching & replacing of content in file1 with file2

I have file 1 & file 2 with content mentioned below. I want to get the output as shown in file3. Requirement: check the content of column 1 & column 2, if value of column 1 in file1 matches with first column of file2 then remaining columns(2&3) of file2 should get replaced, also if value of... (4 Replies)
Discussion started by: siramitsharma
4 Replies

6. Shell Programming and Scripting

Based on column in file1, find match in file2 and print matching lines

file1: file2: I need to find matches for any lines in file1 that appear in file2. Desired output is '>' plus the file1 term, followed by the line after the match in file2 (so the title is a little misleading): This is honestly beyond what I can do without spending the whole night on it, so I'm... (2 Replies)
Discussion started by: pathunkathunk
2 Replies

7. Shell Programming and Scripting

Compare file1 for matching line in file2 and print the difference in matching lines

Hello, I have two files file 1 and file 2 each having result of a query on certain database tables and need to compare for Col1 in file1 with Col3 in file2, compare Col2 with Col4 and output the value of Col1 from File1 which is a) not present in Col3 of File2 b) value of Col2 is different from... (2 Replies)
Discussion started by: RasB15
2 Replies

8. Shell Programming and Scripting

Replacing first field of file2 with the second filed of file1 for matching cases

Dear All, Need your help..:D I am not regular on shell scripts..:( I have 2 files.. Content of file1 cellRef 4};"4038_2_MTNL_KALAMBOLI" cellRef 1020};"4112_3_RAINBOW_BLDG" cellRef 134};"4049_2_TATA_HOSPITAL" cellRef 1003};"4242_3_HITESH_CONSTRUCTION" cellRef... (6 Replies)
Discussion started by: ailnilanjan
6 Replies

9. UNIX for Dummies Questions & Answers

Compare file1 and file2, print matching lines in same order as file1

I want to print only the lines in file2 that match file1, in the same order as they appear in file 1 file1 file2 desired output: I'm getting the lines to match awk 'FNR==NR {a++}; FNR!=NR && a' file1 file2 but they are in sorted order, which is not what I want: Can anyone... (4 Replies)
Discussion started by: pathunkathunk
4 Replies

10. Shell Programming and Scripting

awk to search field2 in file2 using range of fields file1 and using match to another field in file1

I am trying to use awk to find all the $2 values in file2 which is ~30MB and tab-delimited, that are between $2 and $3 in file1 which is ~2GB and tab-delimited. I have just found out that I need to use $1 and $2 and $3 from file1 and $1 and $2of file2 must match $1 of file1 and be in the range... (6 Replies)
Discussion started by: cmccabe
6 Replies
ClonalFrame(1)						      General Commands Manual						    ClonalFrame(1)

NAME
ClonalFrame - inference of bacterial microevolution using multilocus sequence data SYNOPSIS
ClonalFrame [OPTIONS] inputfile outputfile DESCRIPTION
ClonalFrame identifies the clonal relationships between the members of a sample, while also estimating the chromosomal position of homolo- gous recombination events that have disrupted the clonal inheritance. Options: -x NUM Sets the number of iterations after burn-in (default is 50000) -y NUM Sets the number of burn-in iterations (default is 50000) -z NUM Sets the number of iterations between samples (default is 100) -e NUM Sets the number of branch-swapping moves per iterations (default is so that half of the time is spent branch-swapping) -m NUM Sets the initial value of theta to NUM (default is Watterson estimate) -d NUM Sets the initial value of delta to NUM (default is 0.001) -n NUM Sets the initial value of nu to NUM (default is 0.01) -r NUM Sets the initial value of R to NUM (default is initial theta/10) -M Do update the value of theta -D Do not update the value of delta -N Do not update the value of nu -R Do not update the value of R -T Do not update the topology -A Do not update the ages of the nodes -G Remove all gaps -H Remove all gaps at non-polymorphic positions -t NUM Indicate which initial tree to use: 0 for a null tree, 1 for a uniformly chosen coalescent tree and 2 for UPGMA tree (default) -w FILE Use Newick file for initial tree -a NUM Sets the first parameter of the beta prior distribution of nu -b NUM Sets the second parameter of the beta prior distribution of nu -U Use uniform priors for rho, theta and delta -B Run in BURST mode -C Run in UPGMA mode with a site-by-site bootstrap procedure -c Run in UPGMA mode with a fragment-by-fragment bootstrap procedure -S NUM Sets the seed for the random number generator to NUM -E NUM Sets the rate of exponential growth (default is 0) -I Ignores first block in the alignment -L Clean-up the alignment before running ClonalFrame -l Minimum distance between two reference sites (default is 50) -v Verbose mode AUTHOR
ClonalFrame was written by Xavier Didelot. This manual page was written by Andreas Tille <tille@debian.org>, for the Debian project (but may be used by others). February 2011 1.2 ClonalFrame(1)
All times are GMT -4. The time now is 08:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy