Sponsored Content
Top Forums Shell Programming and Scripting Match words and fetch data in front of it in second column Post 302687103 by manigrover on Thursday 16th of August 2012 09:25:25 AM
Old 08-16-2012
Match words and fetch data in front of it in second column

Hi all,

I have 2 files

one file contain data like this in one column

Code:
AST3
GSTY4
JST3


second file containign data like this in 2 columns


Code:
AST3(PAXXX),GSTY4(PAXXY)              it is used in diabetes 
KST4                                                     it is used in blood pressure
JST3                                                    it is never applied in oedema

I have match column of first file with second file and if similarty of symbol which are made up of capital alphabets is there then it shuld copy the sentence in front of it

The Expected out put is

Code:
AST3(PAXXX)                               it is used in diabetes
GSTY4(PAXXY)                            it is used in diabetes 
JST3                                            it is never applied in oedema


If it possible to remove the bracket then it will be good in expected output


Code:
AST3                              it is used in diabetes
GSTY4                         it is used in diabetes 
 JST3                                            it is never applied in oedema

---------- Post updated at 08:25 AM ---------- Previous update was at 02:37 AM ----------

Quote:
Originally Posted by manigrover
Hi all,

I have 2 files

one file contain data like this in one column

Code:
AST3
GSTY4
JST3


second file containing data like this in 2 columns


Code:
AST3(PAXXX),GSTY4(PAXXY)              it is used in diabetes 
KST4                                                     it is used in blood pressure
JST3                                                    it is never applied in oedema

I have match column of first file with second file and if similarty of symbol which are made up of capital alphabets is there then it shuld copy the sentence in front of it

If it possible to remove the bracket then it will be good in expected output


Code:
AST3                              it is used in diabetes
GSTY4                         it is used in diabetes 
 JST3                                            it is never applied in oedema


Last edited by manigrover; 08-16-2012 at 10:24 AM..
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

printing words based on column match

pls help Input: file1 word1 text1 word2 text2 word3 text3 file2 word1 text11 word3 text13 can u pls help in getting the same output: file1 text1 text2 text3 (1 Reply)
Discussion started by: bha148
1 Replies

3. Ubuntu

How to compare two columns and fetch the common data with additional column

Dear All, I am new to this forum and please ignore my little knowledge :p I have two types of data (a subset is given below) data version 1: 439798 2 1 451209 1 2 508696 2 1 555760 2 1 582757 1 2 582889 1 2 691827... (2 Replies)
Discussion started by: evoll
2 Replies

4. Shell Programming and Scripting

match sentence and word adn fetch similar words in alist

Hi all, I have ot match sentence list and word list anf fetch similar words in a separate file second file with 2 columns So I want the output shuld be 2 columns like this (3 Replies)
Discussion started by: manigrover
3 Replies

5. Shell Programming and Scripting

Match the word or words and fetch the entries

Hi all, I have 7 words Now I have 1 file which contain data in large number of rows and columns and 6th column contain any of these words or may be more than one words among above 7 words: I want script should search for the above mentioned 7 words in the 6th column ... (9 Replies)
Discussion started by: manigrover
9 Replies

6. Shell Programming and Scripting

Match same file column data

File A B07 U51C 4434 L662C 4412 B07 L64U 612 L651B 4434 B07 L11C 4434 R151B 4434 B05 L12Z 612 L51B 4434 B01 651Z 612 L651C 4434 B04 A51Z 612 L51A 4434 L07 B08D 4434 B1B 4434 B07 RU8D 4434 L51A 4434 B07 L58D 4434 B51C 4434 B07 LA8D 4434 L4B 4434 Now i want File B Output B07... (2 Replies)
Discussion started by: asavaliya
2 Replies

7. Shell Programming and Scripting

Compare 2 files and match column data and align data from 3 column

Hello experts, Please help me in achieving this in an easier way possible. I have 2 csv files with following data: File1 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:36:09,JOB_5340 08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350 08/23/2012... (5 Replies)
Discussion started by: asnandhakumar
5 Replies

8. Shell Programming and Scripting

Find common and fetch what ever in front of it

Hi guys As my previous one is not working now I have a different problem with me one file with entries F2 F3 YUH SUH second fiel several columns like excel sheet (8-9) but my file in text F2 fgf gfhjhjghjghj dhgfhgfh 234324 F3 ... (6 Replies)
Discussion started by: Priyanka Chopra
6 Replies

9. Shell Programming and Scripting

Match columns and fetch whatever in front of it

Hi Solved these kind of issues using these codes But these are not wrking for my attached files can anybody check........ awk 'NR==FNR{X++;next}{if(X){print}}' file1 file2 awk 'NR==FNR{X=$0;next}{n=split($1,P," ");sub($1,"",$0);for(i=1;i<=n;i++){if(X]){print P,$0}}}' file1 FS="\t" file2 ... (6 Replies)
Discussion started by: Priyanka Chopra
6 Replies

10. Shell Programming and Scripting

Match first column entries precisely and fetch whatever in front of it

Hi all I have 2 files: first file AABC TTYP JKBH CVBN NHJK KJHM Second file is AABC,XCYU,JUHD Alllele1 GACXT It is approved study TTYP,JKBH Allele2 PPRD It is clinical trial study JKBH Allele2 PPRD ... (5 Replies)
Discussion started by: Priyanka Chopra
5 Replies
All times are GMT -4. The time now is 07:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy