Sponsored Content
Top Forums Shell Programming and Scripting compare the interval of 2 numbers of input2with interval of several numbers of input1 Post 302336328 by summer_cherry on Tuesday 21st of July 2009 09:52:27 PM
Old 07-21-2009
hope below perl script can help you some

Code:
my %hash=(a=>'1-4', y=>'30-33', b=>'30-42');
my $flag;
while(<DATA>){
	$flag = 0;
	my @ranges = split("[- 	]",$_);
	my $comp = $hash{$ranges[0]};
	my @tmp=split("-", $comp);
	if ($tmp[0]>$ranges[$#ranges] or $tmp[1]<$ranges[1]){
		print $ranges[0]," ",$comp," out of range\n";
	}
	else{
		for(my $i=1;$i<=9;$i+=2){
			if($ranges[$i]<=$tmp[0] and $ranges[$i+1]>=$tmp[1]){
				print $ranges[0]," ",$comp," in range\n";
				$flag = 1;
				last;
			}
		}
		print $ranges[0]," ",$comp," out of range\n" if $flag!=1;
	}
}
__DATA__
a 5-10, 30-40, 45-60, 80-90, 100-120
y	5-10, 30-40, 45-60, 80-90, 91-120
b	5-10, 30-40, 45-60, 80-90, 91-120

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

compare decimal numbers

Hi anyone, i need to compare two decimal numbers i thought that it could be do it with if but... :( So, i'm writing in csh and i really apreciate if anyone can help me if ( $ppl_kn <= $ppl_wb ) then echo "############# KNdiscount model has the lowest perplexity" set... (5 Replies)
Discussion started by: tmxps
5 Replies

2. Shell Programming and Scripting

how to compare big real numbers

Hi everyone, I need to compare 2 big Floating/Real numbers in a script. After the comparission it is showing worng values in my script. echo "Enter value1" read value1 echo "Enter value2" read value2 Result=`echo "if($value1 > $value2) 1" | bc` if ; then echo "$value1 is... (4 Replies)
Discussion started by: padarthy
4 Replies

3. Shell Programming and Scripting

Need Help for interval date

Hello, I need help about a shell script I have a text file with this fields: 2009/01/19 09:33:35: --> ---ORA-28817: PL/SQL function returned an error. 2009/01/19 09:33:35: --> ---ORA-28817: PL/SQL function returned an error. 2009/01/19 09:33:35: --> ---ORA-28817: PL/SQL function returned an... (4 Replies)
Discussion started by: giofai
4 Replies

4. Shell Programming and Scripting

read numbers from file and output which numbers belongs to which range

Howdy experts, We have some ranges of number which belongs to particual group as below. GroupNo StartRange EndRange Group0125 935300 935399 Group2006 935400 935476 937430 937459 Group0324 935477 935549 ... (6 Replies)
Discussion started by: thepurple
6 Replies

5. Shell Programming and Scripting

the smallest number from 90% of highest numbers from all numbers in file

Hello All, I am having problem to find what is the smallest number from 90% of highest numbers from all numbers in file. I am having file with thousands of lines and hundreds of columns. I am familiar mainly with bash but I am open to whatever suggestion witch will lead to the solutions. If I... (11 Replies)
Discussion started by: Apfik
11 Replies

6. UNIX for Dummies Questions & Answers

Print numbers and associated text belonging to an interval of numbers

##### (0 Replies)
Discussion started by: lucasvs
0 Replies

7. Shell Programming and Scripting

While loop in certain interval

Hi Gurus, I have a script which loops a directory to find the file. right now, I want to add time interval which means every 15 minutes it checks the dir once. if all files are found, then exit with 0. if there are some files missing at 6:00am the process exit with 20. the script start at 7:00pm... (15 Replies)
Discussion started by: ken6503
15 Replies

8. Shell Programming and Scripting

Interval merging

I do have a file (file1) with a specified interval of 500 counts file1 0 500 500 1000 1000 1500 1500 2000 2000 2500 2500 3000 3000 3500 3500 4000 4000 4500 4500 5000 5000 5500 5500 6000 6000 6500 6500 7000 7000 7500 7500 8000 (3 Replies)
Discussion started by: Kanja
3 Replies

9. UNIX for Beginners Questions & Answers

Decimal numbers and letters in the same collums: round numbers

Hi! I found and then adapt the code for my pipeline... awk -F"," -vOFS="," '{printf "%0.2f %0.f\n",$2,$4}' xxx > yyy I add -F"," -vOFS="," (for input and output as csv file) and I change the columns and the number of decimal... It works but I have also some problems... here my columns ... (7 Replies)
Discussion started by: echo manolis
7 Replies

10. UNIX for Beginners Questions & Answers

Repetition in a particular interval

Suppose I have a word which is repeating in a string continuously. I have a set of intervals. Then how do I find the number occurrences of that word in those intervals and their location of occurrences. For example - Suppose there is a huge string anfie.......sirn of 10000 letters. Now the word... (2 Replies)
Discussion started by: ANKIT ROY
2 Replies
XtAddTimeOut()															    XtAddTimeOut()

Name
  XtAddTimeOut - register a procedure to be called when a specified time elapses.

Synopsis
  XtIntervalId XtAddTimeOut(interval, proc, client_data)
	 unsigned long interval;
	 XtTimerCallbackProc proc;
	 XtPointer client_data;

Inputs
  interval  Specifies the time interval in milliseconds.

  proc	    Specifies the procedure to be called when the time expires.

  client_data
	    Specifies data to be passed to proc when it is called.

Returns
  A handle of type XtIntervalId that can be used to unregister the timeout procedure with XtRemoveTimeOut().

Availability
  Superseded by XtAppAddTimeOut().

Description
  XtAddTimeOut()  registers a procedure proc, to be called by XtAppNextEvent() with client_data after interval milliseconds elapse.  The pro-
  cedure is called once and automatically unregistered; it will not be called repeatedly every interval milliseconds.

Usage
  XtAddTimeOut() has been superseded by XtAppAddTimeOut(), which performs the same function on a per-application context  basis.   XtAddTime-
  Out()  now  calls  XtAppAddTimeOut()	passing  the  default application context created by XtInitialize().  Very few programs need multiple
  application contexts, and you can continue to use XtAddTimeOut() if you initialize your application  with  XtInitialize().   We  recommend,
  however, that you use XtAppInitialize(), XtAppAddTimeOut(), and the other XtApp*() application context specific functions.

  See XtAppAddTimeOut() for more information.

See Also
  XtAppAddTimeOut(1), XtAppNextEvent(1), XtRemoveTimeOut(1),
  XtTimerCallbackProc(2).

Xt - Event Handling														    XtAddTimeOut()
All times are GMT -4. The time now is 02:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy