Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Search and extract matching patterns Post 302602379 by Peasant on Monday 27th of February 2012 07:12:02 AM
Old 02-27-2012
See if this awk fills your requirment :
Code:
NR==FNR {
split($3,a,","); for (i in a) vl[a[i]] = $1 FS $2 FS vl[a[i]]
}
NR!=FNR {
idx=$1
OFS="\t"
if ( idx in vl ) {
	final[vl[idx]] = final[vl[idx]] OFS idx
	}
}
END {
	for ( z in final )
	print z FS final[z]
}

Save it as program.awk and run :
Code:
awk -f program.awk bigdb.tab file1.tab file2.tab

Also, you have a typo in bigdb.tab, i belive K-ent shoud be K_ent

Hope it works for you
Regards
Peasant.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

removing certain paragraphs for matching patterns

Hi, I have a log file which might have certain paragraphs. Switch not possible Error code 1234 Process number 678 Log not available Error code 567 Process number 874 ..... ...... ...... Now I create an exception file like this. cat text.exp Error code 1234 Process number 874 (7 Replies)
Discussion started by: kaushys
7 Replies

2. Shell Programming and Scripting

AWK: matching patterns in 2 different files

In a directory, there are two different file extensions (*.txt and *.xyz) having similar names of numerical strings (*). The (*.txt) contains 5000 multiple files and the (*.xyz) also contains 5000 multiple files. Each of the files has around 4000 rows and 8 columns, with several unique string... (5 Replies)
Discussion started by: asanjuan
5 Replies

3. Shell Programming and Scripting

Matching patterns

I have a file name in $f. If $f has "-" at the beginning, or "=", or does not have extension ".ry" or ".xt" or ".dat" then cerr would not be empty. Tried the following but having some problems. set cerr = `echo $f | awk '/^-|=|!.ry|!.xt|!.dat/'` (4 Replies)
Discussion started by: kristinu
4 Replies

4. Shell Programming and Scripting

print lines between 2 matching patterns

Hi Guys, I have file like below, I want to print all lines between test1231233 to its 10 occurrence(till line 41) test1231233 qwe qwe qweq123 test1231233 qwe qwe qweq23 test1231233 qwe qwe qweq123 test1231233 qwe qwe qweq123131 (3 Replies)
Discussion started by: jagnikam
3 Replies

5. UNIX for Dummies Questions & Answers

Find records with matching patterns

Hi, I need to find records with a search string from a file. Search strings are provided in a file. For eg. search_String.txt file is like below chicago mexico newark sanhose and the file from where the records need to be fetched is given below src_file:... (1 Reply)
Discussion started by: sbhuvana20
1 Replies

6. Shell Programming and Scripting

awk extract strings matching multiple patterns

Hi, I wasn't quite sure how to title this one! Here goes: I have some already partially parsed log files, which I now need to extract info from. Because of the way they are originally and the fact they have been partially processed already, I can't make any assumptions on the number of... (8 Replies)
Discussion started by: chrissycc
8 Replies

7. Shell Programming and Scripting

Finding matching patterns in two files

Hi, I have requirement to find the matching patterns of two files in Unix. One file is the log file and the other is the error list file. If any pattern in the log file matches the list of errors in the error list file, then I would need to find the counts of the match. For example, ... (5 Replies)
Discussion started by: Bobby_2000
5 Replies

8. Shell Programming and Scripting

How can I extract XML block around matching search string?

I want to extract XML block surrounding search string Ex: print XML block for string "myapp1-ear" surrounded by "<application> .. </application>" Input XML: <?xml version="1.0" encoding="UTF-8"?> <deployment-request> <requestor> <first-name>kchinnam</first-name> ... (16 Replies)
Discussion started by: kchinnam
16 Replies

9. Shell Programming and Scripting

Delete patterns matching

Delete patterns matching OS version: RHEL 7.3 Shell : Bash I have a file like below (pattern.txt). I need to delete all lines starting with the following words (words separated by comma below) and ) character. LOGGING, NOCOMPRESS, TABLESPACE , PCTFREE, INITRANS, MAXTRANS, STORAGE,... (3 Replies)
Discussion started by: John K
3 Replies

10. Shell Programming and Scripting

Extended grep not matching some patterns

i have a file where the hostnames and variables are in same line in below format, am able extract some part variables while otherlike subscriptions and handler is missing. can you please correct me if grep is able to perform this ? cat /tmp/test localhost subscriptions='' handler="genie"... (14 Replies)
Discussion started by: rakeshkumar
14 Replies
dispatch_apply(3)					   BSD Library Functions Manual 					 dispatch_apply(3)

NAME
dispatch_apply -- schedule blocks for iterative execution SYNOPSIS
#include <dispatch/dispatch.h> void dispatch_apply(size_t iterations, dispatch_queue_t queue, void (^block)(size_t)); void dispatch_apply_f(size_t iterations, dispatch_queue_t queue, void *context, void (*function)(void *, size_t)); DESCRIPTION
The dispatch_apply() function provides data-level concurrency through a "for (;;)" loop like primitive: dispatch_queue_t the_queue = dispatch_get_concurrent_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT); size_t iterations = 10; // 'idx' is zero indexed, just like: // for (idx = 0; idx < iterations; idx++) dispatch_apply(iterations, the_queue, ^(size_t idx) { printf("%zu ", idx); }); Like a "for (;;)" loop, the dispatch_apply() function is synchronous. If asynchronous behavior is desired, please wrap the call to dispatch_apply() with a call to dispatch_async() against another queue. Sometimes, when the block passed to dispatch_apply() is simple, the use of striding can tune performance. Calculating the optimal stride is best left to experimentation. Start with a stride of one and work upwards until the desired performance is achieved (perhaps using a power of two search): #define STRIDE 3 dispatch_apply(count / STRIDE, queue, ^(size_t idx) { size_t j = idx * STRIDE; size_t j_stop = j + STRIDE; do { printf("%zu ", j++); } while (j < j_stop); }); size_t i; for (i = count - (count % STRIDE); i < count; i++) { printf("%zu ", i); } FUNDAMENTALS
Conceptually, dispatch_apply() is a convenient wrapper around dispatch_async() and a semaphore to wait for completion. In practice, the dis- patch library optimizes this function. The dispatch_apply() function is a wrapper around dispatch_apply_f(). SEE ALSO
dispatch(3), dispatch_async(3), dispatch_queue_create(3), dispatch_semaphore_create(3) Darwin May 1, 2009 Darwin
All times are GMT -4. The time now is 09:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy