[ubuntu-za] Script error

Walter Leibbrandt walter+ubuntuza at translate.org.za
Tue Apr 14 14:03:09 BST 2009


Alf Stockton wrote:
> Alf Stockton wrote:
>   
>> if [ -f /mnt/backup/mailbackups/*.dotproject.backup.sql ]
>>      then
>>      rm /mnt/backup/mailbackups/*.dotproject.backup.sql
>>      fi
>>
>>
>>     
> To answer my own question. The above would work if there was only one file 
> matching the *.dotproject.backup.sql.
>   
... Or zero.

The following seems to always echo 1, ie. -f returns true if no 
parameters are specified:
if [ -f ]; then echo 1; else echo 0; fi

So the rm-line would always run if there are no files in the glob being 
tested for.

-- 
Walter Leibbrandt                  Software Developer
Recent blogs:
* Firefox-style button with a pop-up menu
http://www.translate.org.za/blogs/walter/en/content/firefox-style-button-pop-menu





More information about the ubuntu-za mailing list