What's the range of possible values? Can you just initialize min to some ridiculously large value?
Some variants of awk might have a problem with an integer of that size; if you get an error message, try with different values.
Another approach might be to initialize it to an empty string, and make a more complex condition to cover that case. Yet another approach might be to have a sentinel variable which is set to 0 initially and then to 1 when max and min are first defined:
Hello every one, I have following data
***CAMPAIGN 1998 CONTRIBUTIONS***
---------------------------------------------------------------------------
NAME PHONE Jan | Feb | Mar | Total Donated
... (12 Replies)
Hi guys!
I'm new to scripting and I need to write a script in awk.
Here is example of file on which I'm working
ATOM 4688 HG1 PRO A 322 18.080 59.680 137.020 1.00 0.00
ATOM 4689 HG2 PRO A 322 18.850 61.220 137.010 1.00 0.00
ATOM 4690 CD ... (18 Replies)
Hi guys,
I already search on the forum but i can't solve this on my own.
I have a lot of files like this:
And i need to print the line with the maximum value in last column but if the value is the same (2 in this exemple for the 3 last lines) i need get the line with the minimum value in... (4 Replies)
Hi,
I have a file which looks like this:
FID IID MISS_PHENO N_MISS N_GENO F_MISS
12AB43131 12AB43131 N 17774 906341 0.01961
65HJ87451 65HJ87451 N 10149 906341 0.0112
43JJ21345 43JJ21345 N 2826 906341 0.003118I would... (11 Replies)
aaa: 3 ms
aaa: 2 ms
aaa: 5 ms
aaa: 10 ms
..........
to get the 3 2 5 10 ...'s min avg and max
something like
min: 2 ms avg: 5 ms max: 10 ms (2 Replies)
I need to find the max/min of columns 1 and 2 of a 2 column file what contains the special character ">".
I know that this will find the max value of column 1.
awk 'BEGIN {max = 0} {if ($1>max) max=$1} END {print max}' input.file
But what if I needed to ignore special characters in the... (3 Replies)
Hi,
I need your kind help to get min and max values from file based on value in $5 .
File1
SP12.3 stc 2240806 2240808 + ID1_N003 ID2_N003T0
SP12.3 sto 2241682 2241684 + ID1_N003 ID2_N003T0
SP12.3 XE 2239943 2240011 + ID1_N003 ID2_N003T0
SP12.3 XE 2240077 2241254 + ID1_N003 ... (12 Replies)
I am trying to get a simple min/max script to work with the below input. Note the special character (">") within it.
Script
awk 'BEGIN{max=0}{if(($1)>max) max=($1)}END {print max}'
awk 'BEGIN{min=0}{if(($2)<min) min=($2)}END {print min}'
Input
-122.2840 42.0009
-119.9950 ... (7 Replies)
Gedcom::Grammar(3pm) User Contributed Perl Documentation Gedcom::Grammar(3pm)NAME
Gedcom::Grammar - a module to manipulate Gedcom grammars
Version 1.16 - 24th April 2009
SYNOPSIS
use Gedcom::Grammar;
my $st = $grammar->structure("GEDCOM");
my @sgr = $grammar->item("DATE");
my @items = $grammar->valid_items;
my $min = $grammar->min;
my $max = $grammar->max;
my @items = $grammar->items;
DESCRIPTION
A selection of subroutines to handle the grammar of a gedcom file.
Derived from Gedcom::Item.
HASH MEMBERS
Some of the more important hash members are:
$grammar->{top}
The top of the grammar tree.
$grammar->{top}{structures}
A reference to a hash mapping the names of all structures to the grammar objects.
METHODS
structures
my $st = $grammar->structure("GEDCOM");
Return the grammar item of the specified structure, if it exists, or undef.
item
my @sgr = $grammar->item("DATE");
Return a list of the possible grammar items of the specified sub-item, if it exists.
min
my $min = $grammar->min;
Return the minimum permissible number of $grammar items
max
my $max = $grammar->max;
Return the maximum permissible number of $grammar items
items
my @items = $grammar->items;
Return a list of tags of the grammar's sub-items
valid_items
my @items = $grammar->valid_items;
Return a hash detailing all the valid sub-items of the grammar item. The key is the tag of the sub-item and the value is an array of
hashes with three members:
grammar => the sub-item grammar
min => the minimum permissible number of these sub-items
max => the maximum permissible number of these sub-items
perl v5.14.2 2012-04-12 Gedcom::Grammar(3pm)