Sponsored Content
Top Forums Shell Programming and Scripting Match and extract data using two files Post 302937272 by jiam912 on Wednesday 4th of March 2015 03:44:46 PM
Old 03-04-2015
Match and extract data using two files

Hello,

Using the information in file 1, I would like to extract from file2 all rows which matchs in column 3.

file 1
Code:
1233
1230
1231
1232

file2
Code:
  65733.00  19775.00  1220
   65733.00  19793.00  1220
   65733.00  19801.00  1220
   65733.00  19809.00  1231
   65733.00  19817.00  1231
   65733.00  19823.00  1220
   65733.00  19837.00  1220
   65733.00  19841.00  1220
   65733.00  19849.00  1232
   65733.00  19857.00  1232
   65733.00  19873.00  1220
   65733.00  19875.00  1220
   65733.00  19881.00  1220
   65733.00  19889.00  1233
   65733.00  19897.00  1233

Output desired
Code:
 65733.00  19761.00  1230
   65733.00  19765.00  1230
   65733.00  19809.00  1231
   65733.00  19817.00  1231
   65733.00  19849.00  1232
   65733.00  19857.00  1232
   65733.00  19889.00  1233
   65733.00  19897.00  1233

I got the output desired using grep -hFf file1 file2, but is there a best solution using awk.

some times the grep can take values even from columns 1 or 2,, and i need to filter the values only using column 3.

Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

extract the relevant data files for a quarter

CTB_KT_OllyotLvos_20081204_164352_200811.txt CTB_KT_LN_utahfwd_20081204_164352_200811.txt CTB_KT_LN_utahfwd_Summ_20081204_164352_200811.txt CTB_KT_PML_astdt_prFr_20081204_210153_200811.txt CTB_KT_PML_astdt_prOt_20081204_210153_200811.txt CTB_KT_PML_astdt_Nopr_20081204_210153_200811.txt... (7 Replies)
Discussion started by: w020637
7 Replies

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

3. Shell Programming and Scripting

Extract data from records that match pattern

Hi Guys, I have a file as follows: a b c 1 2 3 4 pp gg gh hh 1 2 fm 3 4 g h i j k l m 1 2 3 4 d e f g h j i k l 1 2 3 f 3 4 r t y u i o p d p re 1 2 3 f 4 t y w e q w r a s p a 1 2 3 4 I am trying to extract all the 2's from each row. 2 is just an example... (6 Replies)
Discussion started by: npatwardhan
6 Replies

4. Shell Programming and Scripting

How to extract data from indexed files (ISAM files) maintained in an unix server.

Hi, Could someone please assist on a quick way of How to extract data from indexed files (ISAM files) maintained in an UNIX(AIX) server.The file data needs to be extracted in flat text file or CSV or excel format . Usually we have programs in microfocus COBOL to extract data, but would like... (2 Replies)
Discussion started by: devina
2 Replies

5. Shell Programming and Scripting

extract data from 2 files

file 1 WASH7P 17232,18267,18500,20564 17368,18362,18554,21139 file 2 chr1 14969 15038 Exon WASH7P chr1 17232 17368 Exon WASH7P chr1 17258 17368 Exon WASH7P chr1 17605 17742 Exon WASH7P chr1 18267 18362 Exon WASH7P chr1 18267 18366 Exon WASH7P... (5 Replies)
Discussion started by: Diya123
5 Replies

6. Shell Programming and Scripting

AWK to match and merge data from 2 files into 1.

Hello, hopefully this is an easy on for the AWK guru's out there. I'm having some trouble figuring out how to match+merge data in 2 files into 1 single report. I've got my 2 files filtered and delimited, just need to MATCH $3 in file1 to $1 in file2, then put $0 from File1 and $2+$3 from File2... (6 Replies)
Discussion started by: right_coaster
6 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

Match string in two files and add data to one file

Gents, file1 S 65733.00 19793.00 1 0 318592.8 2792489.5 29.1063000008 S 65733.00 19801.00 1 0 323120.8 2789153.6 13.3063000044 S 66009.00 19713.00 1 0 318672.7 2792538.2 30.6063000120 S 65801.00 19799.00 1 ... (2 Replies)
Discussion started by: jiam912
2 Replies

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

10. UNIX for Beginners Questions & Answers

Match patterns between two files and extract certain range of strings

Hi, I need help to match patterns from between two different files and extract region of strings. inputfile1.fa >l-WR24-1:1 GCCGGCGTCGCGGTTGCTCGCGCTCTGGGCGCTGGCGGCTGTGGCTCTACCCGGCTCCGG GGCGGAGGGCGACGGCGGGTGGTGAGCGGCCCGGGAGGGGCCGGGCGGTGGGGTCACGTG... (4 Replies)
Discussion started by: bunny_merah19
4 Replies
ARCMSR(4)						   BSD Kernel Interfaces Manual 						 ARCMSR(4)

NAME
arcmsr -- Areca RAID Controller driver SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file: device pci device scbus device da device arcmsr Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5): arcmsr_load="YES" DESCRIPTION
The arcmsr driver provides support for the Areca ARC-11xx, ARC-12xx, ARC-13xx, ARC-16xx and ARC-18xx series of SAS and SATA RAID controllers. These controllers feature RAID-0, 1, 3, 5, 6, and 10 and JBOD acceleration for up to 16 SATA drives. RAID level and stripe level migration, online capacity expansion, hot insertion/removal, automatic failover and rebuild, and SMART are also supported. Access to the arrays is pro- vided via the SCSI CAM /dev/da? device nodes. A management interface is also present via the /dev/arcmsr? device node. Management tools for i386 and amd64 are available from Areca. HARDWARE
The arcmsr driver supports the following cards: o ARC-1110 o ARC-1120 o ARC-1130 o ARC-1160 o ARC-1170 o ARC-1110ML o ARC-1120ML o ARC-1130ML o ARC-1160ML o ARC-1200 o ARC-1201 o ARC-1210 o ARC-1212 o ARC-1213 o ARC-1214 o ARC-1220 o ARC-1222 o ARC-1223 o ARC-1224 o ARC-1230 o ARC-1231 o ARC-1260 o ARC-1261 o ARC-1270 o ARC-1280 o ARC-1210ML o ARC-1220ML o ARC-1231ML o ARC-1261ML o ARC-1280ML o ARC-1380 o ARC-1381 o ARC-1680 o ARC-1681 o ARC-1880 o ARC-1882 o ARC-1883 FILES
/dev/da? Array block device /dev/arcmsr? Management interface SEE ALSO
da(4), scbus(4) HISTORY
The arcmsr driver first appeared in FreeBSD 5.4. AUTHORS
The driver was written by Erich Chen <erich@areca.com.tw>. BUGS
The driver has been tested on i386 and amd64. It likely requires additional work to function on big-endian architectures. BSD
December 18, 2013 BSD
All times are GMT -4. The time now is 03:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy