bash checking for multiple files

Michael A. Cleverly michael at cleverly.com
Thu May 18 22:58:44 MDT 2006


On 5/17/06, jeff <jeff at parlant.com> wrote:
> In bash:
>
> I know that you can use [ -f file ] to check for file, but is there
> something similar to check if there are any matches to a wild card?
> i.e. [ -? file* ]

Not directly (as a predicate), but you could achieve it with something
along the lines of:

if [ ! -z "`ls -d file* 2> /dev/null`" ]; then
    echo "some file(s) matched"
else
    echo "no files matched"
fi

Michael


More information about the PLUG mailing list