Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Grep certain lines with condition Post 302803549 by MadeInGermany on Tuesday 7th of May 2013 04:28:26 AM
Old 05-07-2013
Code:
awk -F, '!($1 in max) || $2>max[$1] {max[$1]=$2} END {for (i in max) print i FS max[i]}' input

Before reaching the END you don't know what the maximum is, hence cannot immediately print anything - a simple grep cannot work.

Last edited by MadeInGermany; 05-07-2013 at 05:55 AM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep command with AND condition

I want to do a grep with AND condition. I have three files. file1.txt ======== UNIX ...... WINDOWS ........ ORACLE file2.txt ======== UNIX ....... WINDOWS ...and many such files in a directory (6 Replies)
Discussion started by: prasperl
6 Replies

2. Homework & Coursework Questions

Grep line above X condition

1. The problem statement, all variables and given/known data: I have to grep a data file called datebook.txt. The last information in each line is a salary. I have to grep all the lines which precede those lines with 6 figure salaries. I can't SID it, or use Perl. It has to be grep (or egrep or... (3 Replies)
Discussion started by: DrSammyD
3 Replies

3. Shell Programming and Scripting

grep inside if condition - need help

hi i need help with below code. if ] then log "Exiting the script as ID= NULL" log "Please run script first." fi i am calling grep inside this but its not running any ideas why ?? input file is like this -- Msg 102, Level 20, State 1: Server... (4 Replies)
Discussion started by: dazdseg
4 Replies

4. Shell Programming and Scripting

use awk pick value from lines as condition for grep

Hi Folks! I have a file like this 000000006 dist:0.0 FILE ./MintRoute/MultiHopWMEWMA.nc LINE:305:1 NODE_KIND:131 nVARs:4 NUM_NODE:66 TBID:733 TEID:758 000000000 dist:0.0 FILE ./Route/MultiHopLEPSM.nc LINE:266:1 NODE_KIND:131 nVARs:4 NUM_NODE:66 TBID:601 TEID:626 000000001 ... (2 Replies)
Discussion started by: jackoverflow
2 Replies

5. Shell Programming and Scripting

Perl XML, find matching condition and grep lines and put the lines somewhere else

Hi, my xml files looks something like this <Instance Name="New York"> <Description></Description> <Instance Name="A"> <Description></Description> <PropertyValue Key="false" Name="Building A" /> </Instance> <Instance Name="B"> ... (4 Replies)
Discussion started by: tententen
4 Replies

6. Shell Programming and Scripting

grep in the if condition

Hi, In this code can able to match the pattern without case sensitive. Is that possible? if u knw plz help me... code: echo "Enter name to search" read n if ; echo "name found" else echo "Not Found" fi (8 Replies)
Discussion started by: boopal
8 Replies

7. Shell Programming and Scripting

Where condition in grep or awk?

Dear All, I need help.. I am having a csv file. Home_TITLE,People_TITLE,Repo_ALIAS HMN5530,RKY5807,/mine_repo/rike001 HMN5530,SRY6443,/mine_repo/rike001 HMN5530,ARDY001,/mine_repo/rike001 If i have two value in varible RKY5807, HMN5530. how can fetch and store another value... (6 Replies)
Discussion started by: yadavricky
6 Replies

8. UNIX for Dummies Questions & Answers

How to grep with certain condition?

hi all, i have an xml what i have to do is to search for the source id(s1) and if it matches with that in xml then extract the file mask from the name of the file i.e if the file name is idr_%YYYY%%MM%%DD%_%N%.idr then , i want the part after first % and before last % ie in this case ... (5 Replies)
Discussion started by: ramsavi
5 Replies

9. UNIX for Dummies Questions & Answers

Grep with condition

I have file input AAAA_XX_Start> rlong . 0W 130526-11:36:13 10.128.13.226 9.0j RBS_NODE_MODEL_N_1_50 stopfile=/tmp/13019 .. ================================================================================================================= MO ... (2 Replies)
Discussion started by: radius
2 Replies
mlib_VectorMaximum_U8(3MLIB)				    mediaLib Library Functions				      mlib_VectorMaximum_U8(3MLIB)

NAME
mlib_VectorMaximum_U8, mlib_VectorMaximum_S8, mlib_VectorMaximum_S16, mlib_VectorMaximum_S32, mlib_VectorMaximum_F32, mlib_VectorMaxi- mum_D64 - find the maximum value in a vector SYNOPSIS
cc [ flag... ] file... -lmlib [ library... ] #include <mlib.h> mlib_status mlib_VectorMaximum_U8(mlib_u8 *max, const mlib_u8 *x, mlib_s32 n); mlib_status mlib_VectorMaximum_S8(mlib_s8 *max, const mlib_s8 *x, mlib_s32 n); mlib_status mlib_VectorMaximum_S16(mlib_s16 *max, const mlib_s16 *x, mlib_s32 n); mlib_status mlib_VectorMaximum_S32(mlib_s32 *max, const mlib_s32 *x, mlib_s32 n); mlib_status mlib_VectorMaximum_F32(mlib_f32 *max, const mlib_f32 *x, mlib_s32 n); mlib_status mlib_VectorMaximum_D64(mlib_d64 *max, const mlib_d64 *x, mlib_s32 n); DESCRIPTION
Each of these functions finds the maximum value of all elements in a vector. The following equation is used: max[0] = MAX{ x[i] i = 0, 1, ..., (n - 1) } PARAMETERS
Each of the functions takes the following arguments: max Pointer to the maximum value. x Pointer to the first element of the source vector. n Number of elements in the source vector. RETURN VALUES
Each of the functions returns MLIB_SUCCESS if successful. Otherwise it returns MLIB_FAILURE. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
mlib_VectorMinimum_U8(3MLIB), mlib_MatrixMaximum_U8(3MLIB), mlib_MatrixMinimum_U8(3MLIB), attributes(5) SunOS 5.10 10 Nov 2004 mlib_VectorMaximum_U8(3MLIB)
All times are GMT -4. The time now is 12:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy