Sponsored Content
Full Discussion: awk: union regions
Top Forums Shell Programming and Scripting awk: union regions Post 302437378 by Ygor on Wednesday 14th of July 2010 11:22:06 PM
Old 07-15-2010
Can't say I fully understand the requirement, but try...
Code:
$ cat file1
22 55
2222 2230
33 66
44 58
222 240
11 25
22 60
33 45

$ awk '{l=length($1);if(!SP[l]||$1<SP[l])SP[l]=$1;l=length($2);if($2>EP[l])EP[l]=$2}END{for(i in SP)print SP[i] "-" EP[i]}' file1|sort|paste -s -d ,
11-66,222-240,2222-2230

$

 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find union of two files

Is there a command in unix to find the union of two files and removing the union from one of the files? e.g. I have two files input1.txt and input2.txt with the contents below: $ more input1.txt 4 2 3 2 $ more input2.txt 5 4 4 8 2 I want to find the union of the two and... (7 Replies)
Discussion started by: stevefox
7 Replies

2. Shell Programming and Scripting

union of two files

Given two files of the same format (For example number1|text1|number2) what is the command to print lines in file1 which do not occur in file2? diff command seems a bit complicated for me for this purpose. Please help!! Thank you very much. (3 Replies)
Discussion started by: sherkaner
3 Replies

3. Shell Programming and Scripting

Text files union

How can i union two files that each of them contain text to one new file in unix shell scripting or in awk scripting language? (2 Replies)
Discussion started by: tal
2 Replies

4. Web Development

Intersection and union of array by hash

Hi, A piece of script from Perl-cookbook I do not understand, and post here for explanation. The purpose is to find the element in either array (union), and in both array (intersection). Thank you in advance. @a=qw(1 3 5 6 7 8); @b=qw(2 3 5 7 9); foreach $e (@a, @b) {$union{$e}++ &&... (3 Replies)
Discussion started by: yifangt
3 Replies

5. Programming

GDB and GCC union

My concept may sound a bit cryptic but I what some startup information as to how we can use GDB APIs / debugging techniques in programs with GCC when we compile the program. We can definitely tell gcc to link GDB libs also. The ultimate aid would be that when the compiled programs executes it... (4 Replies)
Discussion started by: uunniixx
4 Replies

6. Shell Programming and Scripting

Obtain the names of the flanking regions

Hi I have 2 files; usually the end position in the file1 is the start position in the file2 and the end position in file2 will be the start position in file1 (flanks) file1 Id start end aaa1 0 3000070 aaa1 3095270 3095341 aaa1 3100822 3100894 aaa1 ... (1 Reply)
Discussion started by: anurupa777
1 Replies

7. Shell Programming and Scripting

Assigning the names from overlapping regions

I have 2 files; file 1 having smaller positions that overlap with the positions with positions in file2. file1 aaa 20 22 apple aaa 18 25 banana aaa 12 30 grapes aaa 22 25 melon file2 aaa 18 26 cdded aaa 10 35 abcde I want to get something like this output aaa 18 26 cdded banana... (4 Replies)
Discussion started by: anurupa777
4 Replies

8. Shell Programming and Scripting

Extract Big and continuous regions

Hi all, I have a file like this I want to extract only those regions which are big and continous chr1 3280000 3440000 chr1 3440000 3920000 chr1 3600000 3920000 # region coming within the 3440000 3920000. so i don't want it to be printed in output chr1 3920000 4800000 chr1 ... (2 Replies)
Discussion started by: amrutha_sastry
2 Replies
XIntersectRegion(3X11)						     MIT X11R4						    XIntersectRegion(3X11)

Name
       XIntersectRegion, XUnionRegion, XUnionRectWithRegion, XSubtractRegion, XXorRegion, XOffsetRegion, XShrinkRegion - region arthmetic

Syntax
       XIntersectRegion(sra, srb, dr_return)
	  Region sra, srb, dr_return;

       XUnionRegion(sra, srb, dr_return)
	  Region sra, srb, dr_return;

       XUnionRectWithRegion(rectangle, src_region, dest_region_return)
	  XRectangle *rectangle;
	  Region src_region;
	  Region dest_region_return;

       XSubtractRegion(sra, srb, dr_return)
	  Region sra, srb, dr_return;

       XXorRegion(sra, srb, dr_return)
	  Region sra, srb, dr_return;

       XOffsetRegion(r, dx, dy)
	  Region r;
	  int dx, dy;

       XShrinkRegion(r, dx, dy)
	  Region r;
	  int dx, dy;

Arguments
       dest_region_return
		 Returns the destination region.

       dr_return Returns the result of the computation.  ds Dy move or shrink

       dx
       dy	 Specify the x and y coordinates, which define the amount you want to  the specified region.

       r	 Specifies the region.

       rectangle Specifies the rectangle.

       sra
       srb	 Specify the two regions with which you want to perform the computation.

       src_region
		 Specifies the source region to be used.

Description
       The function computes the intersection of two regions.

       The function computes the union of two regions.

       The function updates the destination region from a union of the specified rectangle and the specified source region.

       The function subtracts srb from sra and stores the results in dr_return.

       The function calculates the difference between the union and intersection of two regions.

       The function moves the specified region by a specified amount.

       The function reduces the specified region by a specified amount.  Positive values shrink the size of the region, and negative values expand
       the region.

See Also
       XCreateRegion(3X11), XDrawRectangle(3X11), XEmptyRegion(3X11)
       X Window System: The Complete Reference, Second Edition, Robert W. Scheifler and James Gettys

															    XIntersectRegion(3X11)
All times are GMT -4. The time now is 01:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy