On Sat, Dec 07, 2002 at 12:13:11PM -0700, Bob Proulx wrote: > Frank Gevaerts <[EMAIL PROTECTED]> [2002-12-07 19:58:00 +0100]: > > On Sat, Dec 07, 2002 at 11:47:54AM -0700, Bob Proulx wrote: > > > You are trying to find files in a directory. Therefore I recommend > > > you use the 'find' command. > > > [..contrived.example...] > > > mp3playlist=$(find . -name '*.jpg' -print) > > > for mp3 in $mp3playlist; do > > > mpg123 $mp3 > > > done > > > > Why not just > > find . -name \*.jpg -exec mpg123 {} \; > > ? > > > > Much shorter, and no problems with number of arguments... > > I was only proposing the mpg123 as an example. I really don't know > what the OP wanted to do with it.
IIRC he wanted to know if there was at least one jpg file in the directory. > You are right that using find's exec and {} avoids the file with > spaces problem. But instead I would use this if I wanted to play > every file. > > find . -name '*.jpg' -print0 | xargs -r0 mpg123 Any special reason not to use -exec (except of course that xargs works with any input, while -exec only with find (obviously)) > > > However, be careful with find. If you do not want to search > > subdirectories, it is probably not what you want. > > Not true! Check out the -maxdepth option. This only searches one > directory deep. The second only operates on the command line files. > > find . -name '*.jpg' -maxdepth 1 -print0 | xargs -r0 mpg123 > find *.jpg -maxdepth 0 -print0 2>/dev/null | xargs -r0 mpg123 Yes indeed. I need to sleep more. Maybe we should change the examples to feed .mp3 files to mpg123 instead of .jpg files... Frank > Bob -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]