Sponsored Content
Top Forums Shell Programming and Scripting matching columns with overlapping value ranges Post 302323417 by kylle345 on Sunday 7th of June 2009 03:59:22 PM
Old 06-07-2009
matching columns with overlapping value ranges

Hi,

I want to match and print columns that match.

So my file looks like this:

h1 20 30 h1 25 27
h2 50 70 h2 90 95
h2 60 80 h2 70 75
h3 130 150 h3 177 190
h4 140 190 h4 300 305

So there are 6 columns. Column 1 and 4 are names. I am able to get the names to match up into rows. But what I want to do next is match columns 2,3,5 and 6. So if columns 2-3 overlap wiht 5-6 then I want to print that line (eg. values 20-30 overlap with 25-27 so they print. But on row 5, 140-190 does not overlap with 300-305 so it wont print).

So the output will look like this:
h1 20 30 h1 25 27
h2 60 80 h2 70 75
h4 140 190 h4 300 305

Basically I have this... it can match columns 1 and 4 but I cant get the other columns to match.

awk -F"\t" '$1==$4 {print $0} ' file1.txt > output.txt


thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

matching columns from two files

Hey, I have two files that have exactly the same format. They are both tab-delimited and contain 12 columns. However the # of rows vary. What I want to do is match columns # 5,6 and 7 between the two files. If they do match exactly (based on numbers) then I want the whole row from file 2 to... (1 Reply)
Discussion started by: phil_heath
1 Replies

2. UNIX for Dummies Questions & Answers

Matching corresponding columns in two different files

Hi to all, I have two separated files: FILE1 "V1" "V2" "V3" Mary James Nicole Robert Francisco Sophie Nancy Antony Matt Josephine Louise Rose Mark Simon Charles FILE2 "V1" "V2" "V3"... (2 Replies)
Discussion started by: eleonoral
2 Replies

3. UNIX for Dummies Questions & Answers

matching columns

Hello experts, I have this problem, I need to match values based on two files, this is what I have: file1 1.1 1.2 1.3 5.5 1.4 1.5 1.6 file2 1 a 2 B 3 C 4 D 5 z (7 Replies)
Discussion started by: Gery
7 Replies

4. Shell Programming and Scripting

extracting columns falling within specific ranges for multiple files

Hi, I need to create weekly files from daily records stored in individual monthly filenames from 1999-2010. my sample file structure is like the ones below: daily record stored per month: 199901.xyz, 199902.xyz, 199903.xyz, 199904.xyz ...199912.xyz records inside 199901.xyz (original data... (4 Replies)
Discussion started by: ida1215
4 Replies

5. IP Networking

Test for overlapping IP ranges

Greetings folks, I have a rather lengthy list of banned IP ranges in iptables. Initially it was constructed as a rather ad-hoc affair, then later I discovered a site which had IP Block By Country lists, and imported several into iptables. If possible, I'd like to be able to verify if the list... (0 Replies)
Discussion started by: putter1900
0 Replies

6. Shell Programming and Scripting

Checking for ranges based on 2 columns

Hi, I have a file with 6 columns. I want to check if column 1 and 2 fall between column 5 and 6 I want to call them as "TRUE_genes" if not then call them as "FALSE_genes". I can do it for checking one column but how to mention about two columns. file1 110371373... (1 Reply)
Discussion started by: Diya123
1 Replies

7. UNIX for Dummies Questions & Answers

Extracting rows from a text file based on the values of two columns (given ranges)

Hi, I have a tab delimited text file with multiple columns. The second and third columns include numbers that have not been sorted. I want to extract rows where the second column includes a value between -0.01 and 0.01 (including both numbers) and the first third column includes a value between... (1 Reply)
Discussion started by: evelibertine
1 Replies

8. Shell Programming and Scripting

Join two files with matching columns

Hi, I need to join two files together with one common value in a column. I think I can use awk or join or a combination but I can't quite get it. Basically my data looks like this, with the TICKER columns matching up in each file File1 TICKER,column 1, column, 2, column, 3, column 4 ... (6 Replies)
Discussion started by: unkleruckus
6 Replies

9. Shell Programming and Scripting

Identify the overlapping and non overlapping regions

file1 chr pos1 pos2 pos3 pos4 1)chr1 1000 2000 3000 4000 2)chr1 1380 1480 6800 7800 3)chr1 6700 7700 1200 2200 4)chr2 8500 9500 5670 6670 file2 chr pos1 pos2 pos3 pos4 1)chr2 8500 9500 5000 6000 2)chr1 6700 7700 1200 2200 3)chr1 1380 1480 6700 7700 4)chr1 1000 2000 4900 5900 I... (2 Replies)
Discussion started by: data_miner
2 Replies

10. Shell Programming and Scripting

Matching first 2 columns..

Hello All, I want to make a file which will have primarily lines of file2 but when first 2 fields matches with the file1 it should have those lines of file1.. example is as below.. file1 a;b;1 c;d f;e t;r;5 file2 b;g a;b c;d v;b f;e t;r (2 Replies)
Discussion started by: ailnilanjan
2 Replies
xlsfonts(1)                                                   General Commands Manual                                                  xlsfonts(1)

NAME
xlsfonts - server font list displayer for X SYNOPSIS
xlsfonts [-display host:dpy] [-l] [-ll] [-lll] [-m] [-C] [-1] [-w width] [-n columns] [-u] [-o] [-fn pattern] DESCRIPTION
xlsfonts lists the fonts that match the given pattern. The wildcard character "*" may be used to match any sequence of characters (includ- ing none), and "?" to match any single character. If no pattern is given, "*" is assumed. The "*" and "?" characters must be quoted to prevent them from being expanded by the shell. OPTIONS
-display host:dpy This option specifies the X server to contact. -d host:dpy Same as -display host:dpy. -l Lists some attributes of the font on one line in addition to its name. -ll Lists font properties in addition to -l output. -lll Lists character metrics in addition to -ll output. -m This option indicates that long listings should also print the minimum and maximum bounds of each font. -C This option indicates that listings should use multiple columns. This is the same as -n 0. -1 This option indicates that listings should use a single column. This is the same as -n 1. -w width This option specifies the width in characters that should be used in figuring out how many columns to print. The default is 79. -n columns This option specifies the number of columns to use in displaying the output. By default, it will attempt to fit as many columns of font names into the number of character specified by -w width. -u This option indicates that the output should be left unsorted. -o This option indicates that xlsfonts should do an OpenFont (and QueryFont, if appropriate) rather than a ListFonts. This is useful if ListFonts or ListFontsWithInfo fail to list a known font (as is the case with some scaled font systems). -fn pattern This option specifies the font name pattern to match. SEE ALSO
X(7), Xserver(1), xset(1), xfd(1), X Logical Font Description Conventions ENVIRONMENT
DISPLAY DISPLAY must be set to get the default host and display to use. BUGS
Doing ``xlsfonts -l'' can tie up your server for a very long time. This is really a bug with single-threaded non-preemptable servers, not with this program. AUTHOR
Mark Lillibridge Jim Fulton Phil Karlton Roland Mainz X Version 11 xlsfonts 1.0.4 xlsfonts(1)
All times are GMT -4. The time now is 04:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy