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? > > 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?
How about: find . -maxdepth 1 -name '*.jpg' -print | grep -q . ? This keeps the shell's wildcard expansion comfortably out of the equation. (The first '.' and the '-print' are redundant with GNU find, but useful on other systems.) -- Colin Watson [[EMAIL PROTECTED]] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]