Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] my next stupid question

On Tue, Jul 03, 2001 at 02:23:44PM +1000, Alister Waller wrote:
> another stupid question.

No such thing. :-)

> I am running a script from a cronjob. part of the script is a for loop. see
> below:
> for i in `ls *.TXT`
> do
>  cat $i >> newfilename
>  mv $i /tmp
> done
> Now, if there are no *.TXT files then I get an error sent back to the owner
> of the crontab file.

A fairly common idiom for this is:

fileList=`echo *.TXT`
if [ "$fileList" != '*' ]; then
    ...(insert other stuff here)

That should do what you want.


Monday is an awful way to spend 1/7th of your life.