🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: [bash] test: too many arguments

#10395
From: J.A. Gutierrez
Date: Mon, 04 Mar 2002 10:00
55 lines
2468 bytes
Benjam�n Albi�ana <benjamin@lamanonegra.net.dhis.org> wrote:

: - -----------------------------------------------------------------------
: #!/bin/bash

	si no usas features especificas de bash y valoras en algo
	la portabilidad, eso deberia ser

	#!/bin/sh

: if test ! -z $(dir -1 /var/spool/news/failed.postings/)

	si en algo valoras la portabilidad, no uses "dir"

: then

	si quieres saber si un directorio esta vacio o no,
	tienes varias formas:

	ls ./* >/dev/null 2>&1 && echo no vacio || echo vacio
	test `ls -1f | wc -l` -ne 2 && echo no vacio || echo vacio

	rmdir $dir && ( echo vacio; mkdir $dir ) || echo no vacio


: mv /var/spool/news/failed.postings/* /var/spool/news/out.going

	
	
: cd /var/spool/news/out.going
: for i in $(dir -1)
: do
: 	/usr/local/bin/toqueteo $i
: done

	si lo que quieres es hacer algo con todos los ficheros
	de un directorio (no nada si no hay nada) es mucho mejor
	hacer, simplemente:

	cd /var/spool/news/out.going
	ls -1 | while read i
	do
		/usr/local/bin/toqueteo "$i"
	done

: fi
: cd /tmp
: su -c "/usr/sbin/fetchnews -nvvv" news
: - -----------------------------------------------------------------------

-- 
PGP and other useless info at      \
http://www.cps.unizar.es/~spd/      \
finger://daphne.cps.unizar.es/spd    \       Timeo Danaos et dona ferentes
ftp://ivo.cps.unizar.es/pub/          \                         (Virgilio)   
Technical Details
Message-ID: <a5vgkp$62m$1@news.unizar.es>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!naxos.belnet.be!news.belnet.be!news.rediris.es!news.unizar.es!not-for-mail
References: <slrna7vpjf.mlg.benjamin@lamanonegra.net.dhis.org>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,f967119e962785f0
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-03-04 01:37:49 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!naxos.belnet.be!news.belnet.be!news.rediris.es!news.unizar.es!not-for-mail
From: "J.A. Gutierrez" <spd@daphne.cps.unizar.es>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: [bash] test: too many arguments
Date: 4 Mar 2002 10:00:57 GMT
Organization: Rank
Lines: 55
Message-ID: <a5vgkp$62m$1@news.unizar.es>
References: <slrna7vpjf.mlg.benjamin@lamanonegra.net.dhis.org>
NNTP-Posting-Host: daphne.cps.unizar.es
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: news.unizar.es 1015236057 6230 155.210.152.20 (4 Mar 2002 10:00:57 GMT)
X-Complaints-To: usenet@news.unizar.es
NNTP-Posting-Date: 4 Mar 2002 10:00:57 GMT
User-Agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (IRIX/6.2 (IP22))