Sponsored Content
Top Forums Shell Programming and Scripting Compare two fields in text files? Post 302699759 by pulikoti on Wednesday 12th of September 2012 08:51:51 AM
Old 09-12-2012
Compare two fields in text files?

Hi,
I have two text files, compare column one in both the files and if it matches then the output should contain the id in column one, the number and the description.

Both the files are sorted. Is there a one liner to get this done, kindly help. Thank you

File 1:
NC_000964 92.33
NC_002570 91.07
NC_002745 97.34
NC_002758 97.40

File 2:
NC_002570 Bacillus chromosome, complete genome
NC_002745 Staphylococcus aureus complete genome
NC_002758 Staphylococcus aureus complete genome
NC_002951 Staphylococcus aureus complete genome

Output:
NC_002570 91.07 Bacillus chromosome, complete genome
NC_002745 97.34 Staphylococcus aureus complete genome

Last edited by pulikoti; 09-12-2012 at 10:03 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare Fields from two text files using key columns

Hi All, I have two files to compare. Each has 10 columns with first 4 columns being key index together. The rest of the columns have monetary values. Using Perl, I want to read one file into hash; check for the key value availability in file 2; then compare the values in the rest of 6... (2 Replies)
Discussion started by: Sangtha
2 Replies

2. Shell Programming and Scripting

Compare two files based on values of fields.

Hi All, I have two files and data looks like this: File1 Contents #Field1,Field2 Dist_Center_file1.txt;21 Dist_Center_file3.txt;20 Dist_Center_file2.txt;20 File2 Contents (*** No Header ***) Dist_Center_file1.txt;23 Dist_Center_file2.txt;20 Dist_Center_file3.txt;20 I have... (4 Replies)
Discussion started by: Hangman2
4 Replies

3. Shell Programming and Scripting

Compare fields in 2 files using AWK

Hi unix gurus, I have a urgent requirement, I need to write a AWK script to compare each fields in 2 files using AWK. Basically my output should be like this. file1 row|num1|num2|num3 1|one|two|three 2|one|two|three file2 row|num1|num2|num3 1|one|two|three 2|one|two|four ... (5 Replies)
Discussion started by: rashmisb
5 Replies

4. Shell Programming and Scripting

AWK Compare files, different fields, output

Hi All, Looking for a quick AWK script to output some differences between two files. FILE1 device1 1.1.1.1 PINGS device1 2.2.2.2 PINGS FILE2 2862 SITE1 device1-prod 1.1.1.1 icmp - 0 ... (4 Replies)
Discussion started by: stacky69
4 Replies

5. Shell Programming and Scripting

compare fields in different files

HI I'm having some troubles to compare and permut diffrent fields indexed with another filed like the following example `: file1 1 1 2 2 3 3 file2 7 1 9 2 10 3 result------------------- (6 Replies)
Discussion started by: yassinegoth
6 Replies

6. Shell Programming and Scripting

Compare fields in files

Hi, I need the most efficient way of comparing the following and arriving at the result I have a file which has entries like, File1: 1|2|5|7|8|2|3|6|3|1 File2: 1|2|3|1|2|7|9|2 I need to compare the entries in these two file with those of a general file, 1|2|3|5|2|5|6|9|3|1... (7 Replies)
Discussion started by: pradebban
7 Replies

7. Shell Programming and Scripting

Compare three files based on two fields

Guys, I tried searching on the internet and I couldn't get the answer for this problem. I have 3 files. First 2 fields of all of them are of same type, say they come from various databases but first two fields in the 3 files means the same. I need to verify the entries that are not present... (4 Replies)
Discussion started by: PikK45
4 Replies

8. UNIX for Dummies Questions & Answers

Compare 2 fields in 2 files

I am trying to compare two files (separted by a pipe) using 2 fields (field 1,3 from fileA and 1,2 from fileB) if the two files match i want the whole record of fileA adding the extra fields left from fileB. 1. A.txt cat|floffy|12|anything|anythings cat|kitty|15|lala|lalala... (6 Replies)
Discussion started by: sabercats
6 Replies

9. Shell Programming and Scripting

Compare fields in two files

Hi, I am trying to check two files based on certain string and field. cat f1 source=\GREP\" hi this \\ source=\SED\" skdmsmd dnksdns source=\PERL\" cat f2 source=\SED\" source=\GREP\" vlamskds amdksk m source=\AWK\" awk \here\" (3 Replies)
Discussion started by: greet_sed
3 Replies

10. UNIX for Beginners Questions & Answers

Is there a UNIX command that can compare fields of files with differing number of fields?

Hi, Below are the sample files. x.txt is from an Excel file that is a list of users from Windows and y.txt is a list of database account. $ head -500 x.txt y.txt ==> x.txt <== TEST01 APP_USER_PROFILE USER03 APP_USER_PROFILE TEST02 APP_USER_EXP_PROFILE TEST04 APP_USER_PROFILE USER01 ... (3 Replies)
Discussion started by: newbie_01
3 Replies
TIGR-GLIMMER(1) 					      General Commands Manual						   TIGR-GLIMMER(1)

NAME
tigr-glimmer -- Fine start/stop positions of genes in genome sequence SYNOPSIS
tigr-extract [genome-file options] DESCRIPTION
Program extract takes a FASTA format sequence file and a file with a list of start/stop positions in that file (e.g., as produced by the long-orfs program) and extracts and outputs the specified sequences. The first command-line argument is the name of the sequence file, which must be in FASTA format. The second command-line argument is the name of the coordinate file. It must contain a list of pairs of positions in the first file, one per line. The format of each entry is: <IDstring>> <start position> <stop position> This file should contain no other information, so if you're using the output of glimmer or long-orfs , you'll have to cut off header lines. The output of the program goes to the standard output and has one line for each line in the coordinate file. Each line contains the IDstring , followed by white space, followed by the substring of the sequence file specified by the coordinate pair. Specifically, the substring starts at the first position of the pair and ends at the second position (inclusive). If the first position is bigger than the second, then the DNA reverse complement of each position is generated. Start/stop pairs that "wrap around" the end of the genome are allowed. OPTIONS
-skip makes the output omit the first 3 characters of each sequence, i.e., it skips over the start codon. This was the behaviour of the previous version of the program. -l makes the output omit an sequences shorter than n characters. n includes the 3 skipped characters if the -skip switch is one. SEE ALSO
tigr-glimmer3 (1), tigr-long-orfs (1), tigr-adjust (1), tigr-anomaly (1), tigr-build-icm (1), tigr-check (1), tigr-codon-usage (1), tigr- compare-lists (1), tigr-extract (1), tigr-generate (1), tigr-get-len (1), tigr-get-putative (1), http://www.tigr.org/software/glimmer/ Please see the readme in /usr/share/doc/tigr-glimmer for a description on how to use Glimmer3. AUTHOR
This manual page was quickly copied from the glimmer web site by Steffen Moeller moeller@debian.org for the Debian system. TIGR-GLIMMER(1)
All times are GMT -4. The time now is 09:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy