shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



>From address@hidden Fri Jul 25 11:57:31 2008
Return-Path: <address@hidden>
X-Sender: address@hidden
X-Apparently-To: address@hidden
X-Received: (qmail 90881 invoked from network); 25 Jul 2008 18:57:28 -0000
X-Received: from unknown (66.218.67.94)
  by m51.grp.scd.yahoo.com with QMQP; 25 Jul 2008 18:57:28 -0000
X-Received: from unknown (HELO mu-out-0910.google.com) (209.85.134.185)
  by mta15.grp.scd.yahoo.com with SMTP; 25 Jul 2008 18:57:27 -0000
X-Received: by mu-out-0910.google.com with SMTP id g7so3450529muf.2
        for <address@hidden>; Fri, 25 Jul 2008 11:57:26 -0700 (PDT)
X-Received: by 10.103.206.4 with SMTP id i4mr1209154muq.69.1217012246431;
        Fri, 25 Jul 2008 11:57:26 -0700 (PDT)
X-Received: by 10.102.247.18 with HTTP; Fri, 25 Jul 2008 11:57:26 -0700 (PDT)
Message-ID: <address@hidden>
Date: Fri, 25 Jul 2008 15:57:26 -0300
To: address@hidden
In-Reply-To: <address@hidden>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
References: <address@hidden>
X-Originating-IP: 209.85.134.185
X-eGroups-Msg-Info: 1:12:0:0:0
From: "Tiago Barcellos Peczenyj" <address@hidden>
Subject: Re: [shell-script] Buscar maior valor de uma array
X-Yahoo-Group-Post: member; u=204465305; 
y=no9cs0VZA9KgqP9RC0tw38NCraZcoJTsGFIXIfrS0Ezp8JkVggE
X-Yahoo-Profile: grande_uosh

Vc pode listar os valores 1 por linha e usar sort + head para pegar o maior=
.

Imagine que XXX =E9 um array com diversos valores:

XXX=3D($RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RAN=
DOM)

$ echo ${XXX[@]}
4688 3497 9586 20402 26564 31029 5504 14058 15520

maior:
$ xargs -n 1 <<< ${XXX[@]} | sort -nr | head -1
31029

menor:
$ xargs -n 1 <<< ${XXX[@]} | sort -n | head -1
3497

xargs -n 1 <<< ${XXX[@]}  equivale a 'echo ${XXX[@]} | xargs -n 1', so
usei uma forma ex=F3tica ;-)



2008/7/25 Felipe <address@hidden>:
> Ol=E1 lista,
>
> Estou aqui com uma array que contem 50 valores.
>
> Bom, o que eu quero e classificar o maior valor e joga-lo em um
> relevancia.txt
>
> Se fosse ao menos 3 valores apenas, dava pra comparar um a um em busca
> do maior valor, no entanto s=E3o muitos valores.
>
> Gostaria de saber se existe , um algoritimo / melhor forma pra
> classificar o maior numero dessa array.
>
> Grato!
>
>=20



--=20
Tiago B Peczenyj
Linux User #405772

http://peczenyj.blogspot.com/
"what does not kill us makes us stronger"


reply via email to

From: Unknown
[Prev in Thread] Current Thread [Next in Thread]