[wellylug] bash script help
Ewen McNeill
wellylug at ewen.mcneill.gen.nz
Thu Jan 27 13:50:26 NZDT 2005
In message <41F835F3.3080105 at remote-assist.co.nz>, Mark Signal writes:
>#!/bin/bash
>if [ -f /var/spool/amavis-ng/problems/*.msg ]; then
>[....]
>If works fine but if there are to many stuck email messages it gives
>the following error:
>
>./problememail.sh: [: too many arguments
>
>presumably the [ -f /var/spool/amavis-ng/problems/*.msg ] causes the
>problem ?
Yes. When it expands to more than one argument (eg, there are two files
in the directory) then there are too many arguments for the "-f" test,
hence the error you get.
You probably want to use something like the return code of ls:
if ls /var/spool/amavis-ng/problems/*.msg >/dev/null 2>&1; then
to test for the presence of files.
Ewen
More information about the wellylug
mailing list