Awk Overlap


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Awk Overlap
# 1  
Old 08-27-2010
Awk Overlap

Based on input1 specific key (column1, 4 and 5) take the values (column 2 and 3) overlap with input2. And Specify names based on output.

input1
Code:
a1    100    200    E1    ABC
a1    300    400    E2    ABC
a1    500    600    E3    ABC
a2    100    200    E1    CDE
a2    300    400    E2    CDE
a2    500    600    E3    CDE
a3    100    200    E1    EFG
a3    300    400    E2    EFG
a3    500    600    E3    EFG
a4    100    200    E1    DEF
a4    300    400    E2    DEF
a4    500    600    E3    DEF
a4    700    800    E4    DEF
a5    100    200    E1    GHI
a5    200    300    I1    GHI
a5    300    400    E2    GHI
a1    100    200    E1    IJK
a1    300    400    E2    IJK
a2    100    200    E1    IJK
a2    300    400    E2    IJK
a1    100    200    E1    PQR
a1    300    400    E2    PQR
a1    500    600    E3    PQR
a1    800    900    E4    PQR

input2

Code:
a1    100    200    E1    ABC
a1    500    600    E3    ABC
a2    300    400    E2    CDE
a2    500    600    E3    CDE
a3    100    200    E1    EFG
a3    300    400    E2    EFG
a4    100    200    E1    DEF
a4    700    800    E4    DEF
a5    100    200    E1    GHI
a5    300    400    E2    GHI
a1    100    170    E1    IJK
a1    300    400    E2    IJK
a2    100    200    E1    IJK
a2    270    400    E2    IJK
a1    100    200    E1    PQR
a1    300    400    E2    PQR
a1    800    900    E4    PQR

output
Code:
a1    300    400    E2    ABC    SE
a2    100    200    E1    CDE    AFE
a3    500    600    E3    EFG    ALE
a4    300    400    E2    DEF    MXE
a4    500    600    E3    DEF    MXE
a5    200    300    I1    GHI    IR
a1    100    170    E1    IJK    A5SS
a2    270    400    E2    IJK    A3SS
a1    500    600    E3    PQR    SE

Naming

Quote:
if middle value is missing name them "SE"
if first value is missing name them "AFE"
if last value is missing name them "ALE"
if 2 middle values are missing name them "MXE"
if 1st value is shorter but still overlapping then name "A5SS"
if last value is shorter but stil overlapping then name "A3SS"
# 2  
Old 08-27-2010
# 3  
Old 08-27-2010
Trust me. It is not. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding the Overlap

Hi Help, I am trying to find a overlap zone by compraing th etwo files which is printed below. File-1 is --- 1011 234 2967 787 235 900 435 654 File 2 is --- 1211 456 595 678 546 678 2967 787 I would like to have a o/p which just read 2967 787,'comm' doesn't seem to do the... (5 Replies)
Discussion started by: Indra2011
5 Replies

2. UNIX for Dummies Questions & Answers

Overlap by two columns

Hi, I want to overlap two files based on two columns in each files. Here I'm overlapping the first two columns of the first file with columns 3 &4 of the second file (Bolded) to get the common lines. File1 ESR1 1 15 ggtga ESR1 7 18 tgcagt FOXA1 3 10 gtgat FOXA1 10 20 tgacc File2... (1 Reply)
Discussion started by: JJ001
1 Replies

3. Shell Programming and Scripting

HELP with AWK one-liner. Need to employ an If condition inside AWK to check for array variable ?

Hello experts, I'm stuck with this script for three days now. Here's what i need. I need to split a large delimited (,) file into 2 files based on the value present in the last field. Samp: Something.csv bca,adc,asdf,123,12C bca,adc,asdf,123,13C def,adc,asdf,123,12A I need this split... (6 Replies)
Discussion started by: shell_boy23
6 Replies

4. Shell Programming and Scripting

awk command to compare a file with set of files in a directory using 'awk'

Hi, I have a situation to compare one file, say file1.txt with a set of files in directory.The directory contains more than 100 files. To be more precise, the requirement is to compare the first field of file1.txt with the first field in all the files in the directory.The files in the... (10 Replies)
Discussion started by: anandek
10 Replies

5. Red Hat

Partition Overlap

I have just purchased a new server running RHELS R6 from a well known supplier. The OS came pre-installed so I (as a previous almost identical server) just finished off the install. I have just been extending one of the partitions and noticed an overlap. Filesystem Size Used Avail... (5 Replies)
Discussion started by: zetex
5 Replies

6. Solaris

Veritas VxVm 3.2 - Cannot unrelocate subdisk due to overlap with existing subdisks

Hi all, New to this forum as well as the world of Veritas Volume Manager. My client is using VxVM 3.2. We just changed one of the disk which is under veritas control. I used the appropriate options in vxdiskadm to replace this failed disk. Now when I am trying to unrelocate subdisks back to the... (0 Replies)
Discussion started by: rajan_g4
0 Replies

7. Shell Programming and Scripting

Complex overlap and naming of 2 input files - Awk

for every specific $1,$2 check the values ($2,$3) of their E ot I of input1 and overlap with input2. Specify names based on output. ####### if middle value is missing name them "SE" if first value is missing name them "AFE" if last value is missing name them "ALE" if 2 middle values are... (1 Reply)
Discussion started by: ruby_sgp
1 Replies

8. Shell Programming and Scripting

multiple processes overlap

Hello I've got a script that creates multiple processes, in ksh, to bcp out 6 tables at a time. In the script, we write messages to the log to show our progress; most of the time, the log messages are nice and neat with one per line, like they should be. But every once in awhile, at random, the... (2 Replies)
Discussion started by: stonemonolith
2 Replies

9. Shell Programming and Scripting

Finding Overlap between two sets of data

Hi everyone, I posted this earlier, but the idea changed since then and I figured it would make more sense if I repost with a clearer idea in hopes someone can help me out. I have two lists of data in file1 and file 2 file1 (tab separated - column1 column2 column 3) 1 91625106 ... (1 Reply)
Discussion started by: labrazil
1 Replies
Login or Register to Ask a Question