The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
SED - adding blank line after each Range Match danmauer Shell Programming and Scripting 5 06-10-2009 05:27 PM
read numbers from file and output which numbers belongs to which range thepurple Shell Programming and Scripting 6 05-13-2009 07:07 AM
Using grep on a range of numbers ProgChick2oo9 UNIX for Dummies Questions & Answers 1 03-15-2009 03:58 PM
Match a specific IP range sylaan Shell Programming and Scripting 5 07-16-2008 07:42 AM
grep numbers range azmathshaikh Shell Programming and Scripting 1 08-08-2005 08:45 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-21-2009
repinementer repinementer is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 158
match range of different numbers by AWK

if the column1 and 2 in both files has same key (for example "a" and "a1") compare each first key value(a1 of a) of input2 (for example 1-4 or 65-69 not 70-100 or 44-40 etc) with all the values in input1.
if the range of first key value in input2 is outof range in input1 values named it as out of range1 or vice versa.
some of the key values in input2 are in descending order and some are in ascending order. based on these order we have to name them accordingly as I shown below.

If it seems complicated and time consuming please give me any basic idea or approach to compare ranges of 2 files

Help would be appreciated


Code:
input1

a	a1	5-10
		30-40
		45-60
		80-90
		100-120

input2

a	a1	1-4
a	a1	4-1
a	a1	120-140
a	a1	140-120
a	a1	65-69
		70-100
a	a1	70-65
		44-40
a	a1	30-33
		37-57
		63-83
a	a1	85-81
		30-25
b	b1	100-200
c	c2	1-200
d	d3	2-333

output

a	a1	1-4		outofrange1
a	a1	4-1		outofrange2
a	a1	120-140     outofrange3
a	a1	140-12      outofrange4
a	a1	65-69	        inrange1
		70-100
a	a1	70-65  	inrange2
		44-40	
a	a1	30-33 	inrange3
		37-57
		63-83 
a	a1	85-81 	inrange4
		30-25

[COLOR="#738fbf"]

---------- Post updated at 01:34 AM ---------- Previous update was at 12:21 AM ----------

---------- Post updated at 01:35 AM ---------- Previous update was at 01:34 AM ----------

If it seems complicated and time consuming please give me any basic idea or approach to compare ranges of 2 files

Last edited by repinementer; 07-21-2009 at 05:38 AM..
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0