Sponsored Content
Top Forums Shell Programming and Scripting Filtering out duplicates with the highest version number Post 302723243 by Yoda on Monday 29th of October 2012 06:22:56 PM
Old 10-29-2012
Code:
awk -F_ ' { a=$1; b=$2; getline; c=$1; d=$2; if(a==c) { if(b<d) $0=$0; } else { getline; $0=""; e=$1; f=$2; if(d<f) $0=""; } }  { print; } '  infile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find the highest number in the file

Hi, I have a file a.txt and it has values in it Eg :- I need to read through the file and find the number that is the greatest in them all. Can any one assit me on this. Thanks (30 Replies)
Discussion started by: systemali
30 Replies

2. Shell Programming and Scripting

Extract the highest number out

Hi Gurus, I've using HPUX B.11.23 U ia64 with shell = sh. I've been having some problem get the highest number of this script. Actually I wanted to get the highest number from this listing (TEST123 data and based on this highest number, there will be email being sent out. For example,... (6 Replies)
Discussion started by: superHonda123
6 Replies

3. Shell Programming and Scripting

Find highest number - working but need help!

Hello all, I am new to this and need some help or maybe steer me to the right direction! I wrote a script to get the highest number and prints it on the screen, the script basically asks the user to input numbers, and then prints the highest number! very simple it works like this $sh max.sh... (8 Replies)
Discussion started by: unknownsolo
8 Replies

4. Shell Programming and Scripting

Only print the entries with the highest number?

Just want to say this is great resources for all thing Unix!! cat tmp.txt A 3 C 19 A 2 B 5 A 1 A 0 C 13 B 9 C 1 Desired output: A 3 B 9 C 19 The following work but I am wondering if there is a better way to do it: (4 Replies)
Discussion started by: chirish
4 Replies

5. UNIX for Dummies Questions & Answers

Filtering the duplicates

Hello, I want to filter all the duplicates of a record to one place. Sample input and output will give you better idea. I am new to unix. Can some one help me on this? Input: 7488 7389 chr1.fa chr1.fa 3546 9887 chr5.fa chr9.fa 7387 7898 chrX.fa chr3.fa 7488 7389 chr1.fa chr1.fa... (2 Replies)
Discussion started by: koneru_18
2 Replies

6. Shell Programming and Scripting

Need to print duplicate row along with highest version of original

There are some duplicate field on description column .I want to print duplicate row along with highest version of number and corresponding description column. file1.txt number Description === ============ 34567 nl21a00is-centerdb001:ncdbareq:Error in loading init 34577 ... (7 Replies)
Discussion started by: vijay_rajni
7 Replies

7. Shell Programming and Scripting

PERL "filtering the log file removing the duplicates

Hi folks, I have a log file in the below format and trying to get the output of the unique ones based on mnemonic IN PERL. Could any one please let me know with the code and the logic ? Severity Mnemonic Log Message 7 CLI_SCHEDULER Logfile for scheduled CLI... (3 Replies)
Discussion started by: scriptscript
3 Replies

8. Shell Programming and Scripting

Filtering duplicates based on lookup table and rules

please help solving the following. I have access to redhat linux cluster having 32gigs of ram. I have duplicate ids for variable names, in the file 1,2 are duplicates;3,4 and 5 are duplicates;6 and 7 are duplicates. My objective is to use only the first occurrence of these duplicates. Lookup... (4 Replies)
Discussion started by: ritakadm
4 Replies

9. Shell Programming and Scripting

Sort from highest to lowest number

Hi Guys, I am looking for a way to sort the output below from the "Inuse" count from Highest to Lowest. Is it possible? Thanks in advance. user1 0.12 0.06 0 0.12 User Inuse Pin Pgsp Virtual Unit:... (4 Replies)
Discussion started by: jaapar
4 Replies

10. Shell Programming and Scripting

Need to show highest version line from the list

Hi All, Need help here, can you tell me the syntax to line grep the highest file version? 0 04-05-2016 08:00 lib/SBSSchemaProject.jar/schemas/ 0 04-05-2016 08:00 lib/SBSSchemaProject.jar/schemas/airprice/ 0 04-05-2016 08:00 ... (2 Replies)
Discussion started by: 100rin
2 Replies
GETDELIM(3)						   BSD Library Functions Manual 					       GETDELIM(3)

NAME
getdelim, getline -- read a delimited record from a stream LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdio.h> ssize_t getdelim(char ** restrict lineptr, size_t * restrict n, int delimiter, FILE * restrict stream); ssize_t getline(char ** restrict lineptr, size_t * restrict n, FILE * restrict stream); DESCRIPTION
The getdelim() function reads from the stream until it encounters a character matching delimiter, storing the input in *lineptr. The buffer is NUL-terminated and includes the delimiter. The delimiter character must be representable as an unsigned char. If *n is non-zero, then *lineptr must be pre-allocated to at least *n bytes. The buffer should be allocated dynamically; it must be possible to free(3) *lineptr. getdelim() ensures that *lineptr is large enough to hold the input, updating *n to reflect the new size. The getline() function is equivalent to getdelim() with delimiter set to the newline character. RETURN VALUES
The getdelim() and getline() functions return the number of characters read, including the delimiter. If no characters were read and the stream is at end-of-file, the functions return -1. If an error occurs, the functions return -1 and the global variable errno is set to indi- cate the error. The functions do not distinguish between end-of-file and error, and callers must use feof(3) and ferror(3) to determine which occurred. EXAMPLES
The following code fragment reads lines from a file and writes them to standard output. char *line = NULL; size_t linesize = 0; ssize_t linelen; while ((linelen = getline(&line, &linesize, fp)) != -1) fwrite(line, linelen, 1, stdout); if (ferror(fp)) perror("getline"); ERRORS
[EINVAL] lineptr or n is a NULL pointer. [EOVERFLOW] More than SSIZE_MAX characters were read without encountering the delimiter. The getdelim() and getline() functions may also fail and set errno for any of the errors specified in the routines fflush(3), malloc(3), read(2), stat(2), or realloc(3). SEE ALSO
ferror(3), fgets(3), fopen(3) STANDARDS
The getdelim() and getline() functions conform to IEEE Std 1003.1-2008 (``POSIX.1''). BSD
June 30, 2010 BSD
All times are GMT -4. The time now is 10:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy