Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Any 'shortcut' to doing this search for duplicate and print max Post 302967692 by RudiC on Friday 26th of February 2016 10:59:09 AM
Old 02-26-2016
You know awk works on pattern {action} pairs with the default action being {print}.
!T[$2]++ is a pattern (The logical value of empty or zero strings is FALSE, the logical negation will make it TRUE), which reads
if T[$2] is empty, print, increment T[$2] (so any further references will "fail" = print on first occurrence only).
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to print mon and max values of ranges

HI all I'm trying to write an awk script to print the min and max value in a range(s) contained in another file - the range values are in $2 EG 114,7964,1,y,y,n 114,7965,1,y,y,n 114,7966,1,y,y,n 114,7967,1,y,y,n 114,7969,1,y,y,n 114,7970,1,y,y,n 114,7971,1,y,y,n 114,7972,1,y,y,n... (3 Replies)
Discussion started by: Mudshark
3 Replies

2. Shell Programming and Scripting

Search max value in a column in a file instead of sort

Hi Everyone, 1.txt 00:00:00 0 0 0 0 0 0 0 00:00:01 0 0 0 2 1 33 2 00:00:02 5 0 0 0 0 0 0 00:00:03 0 4 0 0 0 0 0... (5 Replies)
Discussion started by: jimmy_y
5 Replies

3. Shell Programming and Scripting

print max number of 2 columns - awk

Is it possible to print max number of 2 columns - awk note: print max if the integer is positive and print min if the integer is negative input a 1 2 b 3 4 c 5 1 d -3 -5 d -5 -3 output a 2 b 4 c 5 d -5 d -5 (4 Replies)
Discussion started by: quincyjones
4 Replies

4. Shell Programming and Scripting

Print min and max value from two column

Dear All, I have data like this, input: 1254 10125 1254 10126 1254 10127 1254 10128 1254 10129 1255 10130 1255 10131 1255 10132 1255 10133 1256 10134 1256 10135 1256 10137... (3 Replies)
Discussion started by: aksin
3 Replies

5. Shell Programming and Scripting

Median and max of duplicate rows

Hi all, plz help me with this, I want to to extract the duplicate rows (column 1) in a file which at least repeat 4 times. then I want to summarize them by getting the max , mean, median and min. The file is sorted by column 1, all the repeated rows appear together. If number of elements is... (5 Replies)
Discussion started by: ritakadm
5 Replies

6. Shell Programming and Scripting

Sum value in a row and print the max

I have the input file in attached. I want the output file : Date , Time , Max_Bearer 11/01/2013 , 23:00 , 1447.894167 11/02/2013 , 00:00 , 1429.266667 11/03/2013 , 00:00 , 712.3175 11/04/2013 , 22:00 , 650.9533333 11/05/2013 , 23:00 , 665.9558333 11/06/2013 , 23:00 , 659.8616667... (2 Replies)
Discussion started by: justbow
2 Replies

7. Shell Programming and Scripting

Search pattern on logfile and search for day/dates and skip duplicate lines if any

Hi, I've written a script to search for an Oracle ORA- error on a log file, print that line and the .trc file associated with it as well as the dateline of when I assumed the error occured. In most it is the first dateline previous to the error. Unfortunately, this is not a fool proof script.... (2 Replies)
Discussion started by: newbie_01
2 Replies

8. Shell Programming and Scripting

Print root number between min and max ranges

Hi to all, Please help on the following problem, I'm not where to begin, if awk or shell script. I have pairs of ranges of numbers and I need to find the root or roots of ranges based on min Range and Max ranges Example #1: If min range is 120000 and max ranges 124999, it means that are... (5 Replies)
Discussion started by: Ophiuchus
5 Replies

9. Shell Programming and Scripting

Find Max value of line and print

I need to find the max value of all columns except the 1st column and print the answer along with the 1st column. Input 123xyz 0 0 1 2 0 0 0 0 0 0 0 234xyz 0 0 0 0 0 0 0 0 0 0 0 345xyz 0 0 1 0 0 0 ... (8 Replies)
Discussion started by: ncwxpanther
8 Replies

10. UNIX for Beginners Questions & Answers

Print a row with the max number in a column

Hello, I have this table: chr1_16857_17742 - chr1 17369 17436 "ENST00000619216.1"; "MIR6859-1"; - 67 chr1_16857_17742 - chr1 14404 29570 "ENST00000488147.1"; "WASH7P"; - 885 chr1_16857_18061 - chr1 ... (5 Replies)
Discussion started by: coppuca
5 Replies
XrmGetResource(3X11)						     MIT X11R4						      XrmGetResource(3X11)

Name
       XrmGetResource, XrmQGetResource, XrmQGetSearchList, XrmQGetSearchResource - retrieve database resources and search lists

Syntax
       Bool XrmGetResource(database, str_name, str_class, str_type_return, value_return)
	  XrmDatabase database;
	  char *str_name;
	  char *str_class;
	  char **str_type_return;
	  XrmValue *value_return;

       Bool XrmQGetResource(database, quark_name, quark_class, quark_type_return, value_return)
	  XrmDatabase database;
	  XrmNameList quark_name;
	  XrmClassList quark_class;
	  XrmRepresentation *quark_type_return;
	  XrmValue *value_return;

       typedef XrmHashTable *XrmSearchList;

       Bool XrmQGetSearchList(database, names, classes, list_return, list_length)
	  XrmDatabase database;
	  XrmNameList names;
	  XrmClassList classes;
	  XrmSearchList list_return;
	  int list_length;

       Bool XrmQGetSearchResource(list, name, class, type_return, value_return)
	  XrmSearchList list;
	  XrmName name;
	  XrmClass class;
	  XrmRepresentation *type_return;
	  XrmValue *value_return;

Arguments
       class	 Specifies the resource class.

       classes	 Specifies a list of resource classes.

       database  Specifies the database that is to be used.

       list	 Specifies the search list returned by

       list_length
		 Specifies the number of entries (not the byte size) allocated for list_return.

       list_return
		 Returns a search list for further use.

       name	 Specifies the resource name.

       names	 Specifies a list of resource names.

       quark_class
		 Specifies the fully qualified class of the value being retrieved (as a quark).

       quark_name
		 Specifies the fully qualified name of the value being retrieved (as a quark).

       quark_type_return
		 Returns a pointer to the representation type of the destination (as a quark).

       str_class Specifies the fully qualified class of the value being retrieved (as a string).

       str_name  Specifies the fully qualified name of the value being retrieved (as a string).

       str_type_return
		 Returns a pointer to the representation type of the destination (as a string).

       type_return
		 Returns data representation type.

       value_return
		 Returns the value in the database.

Description
       The and functions retrieve a resource from the specified database.  Both take a fully qualified name/class pair, a destination resource
       representation, and the address of a value (size/address pair).	The value and returned type point into database memory; therefore, you
       must not modify the data.

       The database only frees or overwrites entries on or A client that is not storing new values into the database or is not merging the data-
       base should be safe using the address passed back at any time until it exits.  If a resource was found, both and return otherwise, they
       return

       The function takes a list of names and classes and returns a list of database levels where a match might occur.	The returned list is in
       best-to-worst order and uses the same algorithm as for determining precedence.  If list_return was large enough for the search list,
       returns otherwise, it returns

       The size of the search list that the caller must allocate is dependent upon the number of levels and wildcards in the resource specifiers
       that are stored in the database.  The worst case length is 3n, where n is the number of name or class components in names or classes.

       When using followed by multiple probes for resources with a common name and class prefix, only the common prefix should be specified in the
       name and class list to

       The function searches the specified database levels for the resource that is fully identified by the specified name and class.  The search
       stops with the first match.  returns if the resource was found; otherwise, it returns

       A call to with a name and class list containing all but the last component of a resource name followed by a call to with the last component
       name and class returns the same database entry as and with the fully qualified name and class.

See Also
       XrmInitialize(3X11), XrmMergeDatabases(3X11), XrmPutResource(3X11), XrmUniqueQuark(3X11)
       X Window System: The Complete Reference, Second Edition, Robert W. Scheifler and James Gettys

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