Sponsored Content
Full Discussion: finding max size
Top Forums Shell Programming and Scripting finding max size Post 302555433 by Corona688 on Wednesday 14th of September 2011 05:48:38 PM
Old 09-14-2011
That's what I get for answering too fast... Here's a solution that does what you want:

Code:
$ awk '{       A[ $1 "#" $2 ]++;       }
END {   for(K in A)
        {
                split(K, L, "#");
                STR=L[1]        ;       VAL=L[2]

                if(C[STR] <= A[K])
                {
                        C[STR]=A[K];
                        T[STR]=VAL
                }
        }

        for(K in T)     print K, T[K];
} < data
ABC 4
XYZ 3
DEF 2
$

There's an inconsistency in your example though. If we get a pattern like
Code:
A 1
A 1
A 2
A 2

which should be chosen, 1 or 2? Your example has ABC choosing the first max and DEF choosing the last max...

To choose the first instead of the last, change
Code:
if(C[STR] <= A[K])

to
Code:
if(C[STR] < A[K])

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Max size of variable

What is the maximum amount of characters that you can have in a varible name in the ksh shell? (1 Reply)
Discussion started by: lesstjm
1 Replies

2. UNIX for Dummies Questions & Answers

Max I/O Size

My HP-UX 11.0 system is supporting an Oracle database. I have found a number of references on the Net to the "Max I/O size" in relation to setting Oracle parameters. How can I tell what my max i/o size is? I originally made the assumption that it was referring to my stripe size but now I think... (1 Reply)
Discussion started by: keelba
1 Replies

3. Shell Programming and Scripting

Finding max value

My code below is supposed to find which company had the most business and then print the appropriate fields from another file which are the companies ID number and name. I can loop through awk and display all the total amount of business for each company but I need help in only printing out the... (1 Reply)
Discussion started by: Enigma23
1 Replies

4. Shell Programming and Scripting

finding duplicate files by size and finding pattern matching and its count

Hi, I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern. Note:These are the samples of two files,but i can have more... (2 Replies)
Discussion started by: jerome Sukumar
2 Replies

5. Solaris

max. size of file

I wants to ask that what is the max size of file that we can create in the unix file system. (2 Replies)
Discussion started by: sameerghogre
2 Replies

6. UNIX for Advanced & Expert Users

Max. file size

i want to know what is the maximum file size supported by linux with ext3 file system. (1 Reply)
Discussion started by: nagalenoj
1 Replies

7. Shell Programming and Scripting

Help in finding the max and min position

Hi, I have this input file called ttbitnres (which is catenated and sorted):- 8 0.4444 213 10 0.5555 342 11 0.5555 321 12 0.5555 231 13 0.4444 400 My code is at :- #!/bin/bash echo -e Version "\t" Number of Pass "\t" Number of Fail "\t" Rank Position "\t"Min "\t" Max... (1 Reply)
Discussion started by: ahjiefreak
1 Replies

8. Shell Programming and Scripting

Finding Max value from an array

Hi, I need to find max and second max element from an array. array contains 0338,0337,0339,0340,0401,0402,0403 (10 Replies)
Discussion started by: vjasai
10 Replies

9. Shell Programming and Scripting

Finding max number in filename and opening it

Hi, I have files named as energy.dat.1 energy.dat.2 energy.dat.3 ... energy.dat.2342 I would like to find the file with maximum number in the filename (ex. energy.dat.2342) and open it. Would you please share your expertize in writing the script? Thanks in advance. (8 Replies)
Discussion started by: rpd25
8 Replies

10. Shell Programming and Scripting

Finding max of a column grouping by the time

Hi, I have the below text: 16:00 0.50 16:00 0.30 16:00 0.00 16:00 0.00 16:00 0.30 16:01 0.00 16:01 0.30 I want to find the max of the 2nd column grouping by the values in the 1st column using awk. So 16:00 0.50 16:01 0.30 I have tried (3 Replies)
Discussion started by: satishrao
3 Replies
SUMO(1) 							   User Commands							   SUMO(1)

NAME
SUMO - Router for the microscopic road traffic simulation SUMO based on junction turning ratios SYNOPSIS
jtrrouter [OPTION]* DESCRIPTION
SUMO jtrrouter Version 0.15.0 Copyright (C) 2001-2012 DLR and contributors; http://sumo.sourceforge.net Router for the microscopic road traffic simulation SUMO based on junction turning ratios. Configuration Options: -c, --configuration-file FILE Loads the named config on startup --save-configuration FILE Saves current configuration into FILE --save-template FILE Saves a configuration template (empty) into FILE --save-schema FILE Saves the configuration schema into FILE --save-commented Adds comments to saved template, configuration, or schema Input Options: -n, --net-file FILE Use FILE as SUMO-network to route on -d, --taz-files FILE Read (additional) districts from FILE -a, --alternative-files FILE Read alternatives from FILE -f, --flow-files FILE Read flow-definitions from FILE(s) -t, --turn-ratio-files FILE Read turning ratios from FILE(s) Output Options: -o, --output-file FILE Write generated routes to FILE --vtype-output FILE Write used vehicle types into separate FILE --exit-times Write exit times (weights) for each edge Processing Options: --ignore-errors Continue if a route could not be build --unsorted-input Assume input is unsorted --randomize-flows generate random departure times for flow input --max-alternatives INT Prune the number of alternatives to INT --remove-loops Remove loops within the route; Remove turnarounds at start and end of the route --repair Tries to correct a false route --weights.interpolate Interpolate edge weights at interval boundaries --with-taz Use origin and destination zones (districts) for in- and output --max-edges-factor FLOAT -T, --turn-defaults STR Use STR as default turn definition -s, --sink-edges STR Use STR as list of sink edges -A, --accept-all-destinations Whether all edges are allowed as sink edges -i, --ignore-vclasses Ignore road restrictions based on vehicle class --allow-loops Allow to re-use a road Defaults Options: --departlane STR Assigns a default depart lane --departpos STR Assigns a default depart position --departspeed STR Assigns a default depart speed --arrivallane STR Assigns a default arrival lane --arrivalpos STR Assigns a default arrival position --arrivalspeed STR Assigns a default arrival speed --defaults-override Defaults will override given values Time Options: -b, --begin TIME Defines the begin time; Previous trips will be discarded -e, --end TIME Defines the end time; Later trips will be discarded; Defaults to the maximum time that SUMO can represent Report Options: -v, --verbose Switches to verbose output -p, --print-options Prints option values before processing -?, --help Prints this screen -V, --version Prints the current version -W, --no-warnings Disables output of warnings -l, --log FILE Writes all messages to FILE (implies verbose) --message-log FILE Writes all non-error messages to FILE (implies verbose) --error-log FILE Writes all warnings and errors to FILE --stats-period INT Defines how often statistics shall be printed --no-step-log Disable console output of route parsing step Random Number Options: --random Initialises the random number generator with the current system time --seed INT Initialises the random number generator with the given value EXAMPLES
jtrrouter -c <CONFIGURATION> run with routing options defined in file REPORTING BUGS
Report bugs at <http://sourceforge.net/apps/trac/sumo/>. Get in contact via <sumo-user@lists.sourceforge.net>. Copyright (C) 2001-2012 DLR and contributors; http://sumo.sourceforge.net SUMO jtrrouter Version 0.15.0 is part of SUMO. SUMO is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/gpl.html SUMO jtrrouter Version 0.15.0 May 2012 SUMO(1)
All times are GMT -4. The time now is 05:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy