En vez de poner el comodín directamente prueba con:

if [ "$(echo *.txt)" ] ; then .......

si no hay archivos la cadena estará vacía dando false, si hay uno o más
será true.

Según he probado eso muestra sólamente *.txt, y por lo tanto siempres es true.

Así funciona.

#!/bin/bash

cd .copia_cd/

if [ $(ls |grep *.gpg) ]; then
        echo "existe archivo"
else
        echo "No hay archivo"
fi

exit


if [ CONDICION1 -o CONDICION2 -o CONDICION3 ]; then ...

-o es el OR

if [ CONDICION1 -a CONDICION2 -a CONDICION3 ]; then ...

-a es el AND

Más info de todos estos trucos en «man test»



Lo que no me acaba de funcionar es el -o

#!/bin/bash

cd .copia_cd/

if [ $(ls |grep *.gpg) -o $(ls | grep *.tar) ]; then
        echo "existe archivo"
else
        echo "No hay archivo"
fi

exit

--
----
Saludos

Pablo


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Responder a