[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RE: bash brace expansion question SOLVED



>On Tue, Feb 04, 2003 at 01:10:45PM -0500, Drew Cohan wrote:
>> Why is
>>
>>
>>
>> echo /path/to/dir/*.{jpg,JPG,jpeg,JPEG}
>>
>>
>>
>> illegal?
>
>It's not, merely not portable to POSIX shells other than bash. However,
>you may want to 'shopt -s nullglob' in case some of the parts of that
>wildcard don't expand to anything.
>
>--
>Colin Watson                                  [cjwatson@flatline.org.uk]

Thanks to all those who responded.  For future googling, the following
solved my problem with brace expansion (test for existence of files in
directory without the use of the find, locate, or xargs command)

#!/bin/sh

shopt -s nullglob

if [ -n "$(echo /tmp/*.{jpg,JPG,jpeg,JPEG})" ]; then
	echo "Files exist"
else
	echo "Files do not exist"
fi

--
Drew Cohan
drew at drewcohan dot com




Reply to: