Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Jul 2008 14:56:27 -0700
From:      Gary Kline <kline@thought.org>
To:        David Kelly <dkelly@hiwaay.net>
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: why is this script failing?
Message-ID:  <20080714215626.GA28814@thought.org>
In-Reply-To: <20080714210924.GA16869@Grumpy.DynDNS.org>
References:  <20080714201241.GA22443@thought.org> <20080714210924.GA16869@Grumpy.DynDNS.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jul 14, 2008 at 04:09:24PM -0500, David Kelly wrote:
> On Mon, Jul 14, 2008 at 01:12:47PM -0700, Gary Kline wrote:
> > 
> > 	why is this script not finding them?
> > 
> > 
> > wav=/tmp/kde-kline/\*wav\*
> > 
> > if [ -s $wav ]
> 
> As others have pointed out because if "/tmp/kde-kline/file1.wav
> /tmp/kde-kline/file2.wav" is found the -s will fail because $wav isn't a
> single file. Or it could be that your escaped wildcards are staying
> escaped.
> 
> I use something like this to move files out of a Maildir:
> 
> #!/bin/sh
> for i in /tmp/kde-kline/*wav
> do
> 	# if nothing or nonsense was found then $i won't exist
> 	if [ -e $i ]
> 	then
> 		echo "Found " $i
> 		/bin/rm $i
> 	fi
> done


	You're right of course, and for the most bothersome hundreds of
	wav and log files this works:


log=/tmp/kde-kline/\*log;
wav=/tmp/kde-kline/\*wav\*;

for f in $wav
do
        if [ -e $f  ]
        then
                ###echo "Wav files found"; ls -l $f;
                /bin/rm ${f};
        fi
done

for f in $log
do
        if [ -e $f  ]
        then
                ###echo "log files found"; ls -l $f;
                /bin/rm ${f};
        fi
done


	But as you point out, the followingisthat much more effective.
	or at least lesss typing.

> 
> But why do it the hard way?
> 
> #!/bin/sh
> /bin/rm /tmp/kde-kline/*wav > /dev/null 2>&1

	with this,
> 
> /bin/rm /tmp/kde-kline/*log > /dev/null 2>&1


	thanks much:-)

	gary


> -- 
> David Kelly N4HHE, dkelly@HiWAAY.net
> ========================================================================
> Whom computers would destroy, they must first drive mad.

-- 
  Gary Kline  kline@thought.org   www.thought.org  Public Service Unix
        http://jottings.thought.org   http://transfinite.thought.org





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080714215626.GA28814>