🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #8101

Re: Tratar variables numericas en bash

#8101
From: marmolejo
Date: Thu, 12 Dec 2002 17:08
47 lines
2278 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


	Autor:  Edgar de la cruz <acrraidx@lycos.es>
	Asunto: Tratar variables numericas en bash
	Fecha:  jueves, 12 de diciembre de 2002
	Hora:   14:12 
	ID. del mensaje: <ata5pc$mh9$1@julieta.escomposlinux.org>

>  Resulta que estaba haciendo un escript en bash con un bucle. Algo as�
>  
>  NUMERIC=0
>  for i in ls *.mp3
>  do
          let NUMERIC=$NUMERIC+1
>  done
>  
>  echo $NUMERIC

pero cuenta de m�s, ser�a mejor:

#!/bin/sh
NUMERIC=0
for i in `ls -c1 *.mp3`
    do
        let NUMERIC=$NUMERIC+1
    done
echo $NUMERIC


Ahora bien, si lo quieres es contar archivos:

ls -l *.mp3|wc -l

- -- 
30 a�os aprendiendo a decir jurgoneta y ahora va y se dice gonomolumen...
  Debian GNU/Linux Sid               <marmolejo at escomposlinux.org>
PGP Pub Key en pgp.escomposlinux.org ID:0x320A57C2 | Linux User #162799   

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9+MKFal36lDIKV8IRAt+YAJ9udLBe0DG+wAMN2seVZYE2cuc6NACeOztp
Q5hX2SEIpYDetjg4lrM52dQ=
=8XgZ
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <slrnavhgk0.c15.marmolejo@porta.til>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn14feed!worldnet.att.net!64.154.60.72!cyclone2.usenetserver.com!news.webusenet.com!news-hub.cableinet.net!blueyonder!marmolejo.escomposlinux.org!porta.til!news
References: <ata5pc$mh9$1@julieta.escomposlinux.org>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,b6beb247a4710747
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-12-12 10:25:42 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn14feed!worldnet.att.net!64.154.60.72!cyclone2.usenetserver.com!news.webusenet.com!news-hub.cableinet.net!blueyonder!marmolejo.escomposlinux.org!porta.til!news
From: marmolejo <marmolejo@escomposlinux.org>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Tratar variables numericas en bash
Date: Thu, 12 Dec 2002 18:08:23 +0100
Organization: Ecolnet
Lines: 47
Message-ID: <slrnavhgk0.c15.marmolejo@porta.til>
References: <ata5pc$mh9$1@julieta.escomposlinux.org>
Reply-To: marmolejo@escomposlinux.org
NNTP-Posting-Host: portatil.debian.home
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
X-Trace: localhost.escomposlinux.org 1039717541 1095 192.168.1.3 (12 Dec 2002 18:25:41 GMT)
X-Complaints-To: newsmaster@marmolejo.escomposlinux.org
NNTP-Posting-Date: Thu, 12 Dec 2002 18:25:41 +0000 (UTC)
User-Agent: slrn/0.9.7.4 (Linux)