On Sat, Jan 04, 2003 at 07:00:03PM -0600, Gerald V. Livingston II wrote: > Colin Watson said: > > > On Tue, Dec 10, 2002 at 11:20:31AM -0800, Osamu Aoki wrote: > >> if [ -e *.JPG ]; then for i in *.JPG; do mv "$i" "${i%.JPG}.jpg"; > >> done fi > > > > That -e test looks dreadful ... surely it'll usually expand to lots of > > arguments which will confuse [, or perhaps to an empty string > > (nullglob) > > which will also confuse test? > > > > -- > > Colin Watson > > [[EMAIL PROTECTED]] > > And I've bumped into this. How *DOES* one test for the existence of > ANY file with a given extension without getting a "too many arguments" > error when there are multiple files? > > I want "TRUE" if there is one or more zzz.jpg files in a directory, > "FALSE" if there are zero of them. >
This is icky but works: shopt -s nullglob SOME=FALSE MATCH=*.jpg for f in $MATCH; do SOME=TRUE; break; done I tried [ -z $MATCH ] also but it always fails even though echo $MATCH prints an empty string. -- Mark -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]