🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Problemas con bash y ficheros con espacios

#5960
From: Gorka Olaizola
Date: Wed, 27 Aug 2003 15:29
56 lines
2970 bytes
Estoy haciendo un script en bash y tengo muchos problemas con los ficheros
con espacios. Lo he intentado de mil formas pero no consigo una soluci�n.
En teor�a lo que hago deber�a funcionar pero creo que por usar /getopts/
algo sale mal. (getopts en una funci�n interna de bash)

[...]
Aqu� llamo a getopts y saco los switches.
[...]

images=$@

goaway=0
for i in $images
do
        if [ ! -r "$i" ]
        then
                echo "The picture \"$i\" does not exists or is unreadable"
                goaway=1
        fi
        numimages=$(($numimages+1))
done

Si pongo esta l�nea de comandos funciona correctamente:

./img2vcd "*.jpg"

Pero si pongo alguna de estas no funciona

./img2vcd "IMG - 00*.jpg"
./img2vcd "IMG - 0001.jpg" "IMG - 0002.jpg"
./img2vcd "IMG - 0001.jpg IMG - 0002.jpg"

El resultado es este

The picture "IMG" does not exists or is unreadable
The picture "-" does not exists or is unreadable
The picture "00*.jpg" does not exists or is unreadable
[...]

En otro caso he logrado hacer funcionar los nombres con espacios metiendo
los ficheros uno por l�nea en un fichero y haciendo esta construcci�n

while read f
do
    variable="$f"
done < "$fichero"

Pero me gustar�a que las im�genes se pudieran especificar desde la l�nea de
comando aunque tengan espacios.

He leido esta p�gina (adem�s de otras) pero tampoco es que me aclare demasiado

http://www.greenend.org.uk/rjk/2001/04/shell.html

-- 
Ahora nosotros somos los cuervos que rompen el silencio...
Technical Details
Message-ID: <slrnbkpjga.1mg.gorka@conn.helvete.escomposlinux.org>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!amsnews01.chello.com!news-hub.cableinet.net!blueyonder!marmolejo.escomposlinux.org!mbytes.escomposlinux.org!helvete.escomposlinux.org!escomposlinux.org!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,7bd7fe9d2d980812,start
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2003-08-27 08:28:20 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!syros.belnet.be!news.belnet.be!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!amsnews01.chello.com!news-hub.cableinet.net!blueyonder!marmolejo.escomposlinux.org!mbytes.escomposlinux.org!helvete.escomposlinux.org!escomposlinux.org!not-for-mail
From: Gorka Olaizola <gorka@helvete.escomposlinux.org>
Newsgroups: es.comp.os.linux.programacion
Subject: Problemas con bash y ficheros con espacios
Date: Wed, 27 Aug 2003 15:29:33 +0000 (UTC)
Organization: ecol.* (http://www.escomposlinux.org)
Lines: 56
Message-ID: <slrnbkpjga.1mg.gorka@conn.helvete.escomposlinux.org>
Reply-To: gorka@escomposlinux.org
NNTP-Posting-Host: conn.helvete.escomposlinux.org
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
X-Trace: helvete.escomposlinux.org 1061998173 1534 192.168.1.3 (27 Aug 2003 15:29:33 GMT)
X-Complaints-To: newsmaster@helvete.escomposlinux.org
NNTP-Posting-Date: Wed, 27 Aug 2003 15:29:33 +0000 (UTC)
X-Face: "$g$3$H0:QS/@0nTw`x=X?.MC;F6!F`/I>A}E>F1@>#,@8Z[I{j*j9mt,T=c1Baf_@FX;)o~rz"9mv_##'_"Qi}c,Tk1PsO>a^1>%y($lqNjYK6\9{:.&\.t$gsZap*0e&a\B:Zf]m&Q)krcpex/B
User-Agent: slrn/0.9.7.4 (Linux)