Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Oct 1998 09:22:10 -0800 (PST)
From:      patl@phoenix.volant.org
To:        Studded <Studded@gorean.org>
Cc:        Jason McNew <jase@clearsail.net>, questions@FreeBSD.ORG
Subject:   Re: find... pilot error?
Message-ID:  <ML-3.3.909422530.3010.patl@asimov>
In-Reply-To: <3634287A.1900A74E@gorean.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> Jason McNew wrote:
> > 
> > After reading the find man page, I tried using:
> > find / -name "*.mp3" -exec mpg123 {};
> > and it tells me:
> > find: -exec: no terminating ";"
> > if I do:
> > find / -name "*.mp3" -exec mpg123 {}\;
> > it runs ok, but mpg123 just gives me syntax help a few times.
> > So, I tried:
> > find / -name "*.mp3" -exec echo {}\;
> > and it just spits out a bunch of blank lines.
> > Although:
> > find / -name "*.mp3" -print
> > works exactly how i'd expect it.

Your shell might be doing something special with the braces.  Try
various other forms of quoting.

>      I don't know what mpg123 expects as an argument, but in a case like
> this I fall back on my shell. Assuming you're using Bash or sh, this
> should work:
> 
> for FILE in `find / -name '\*.mp3'`; do
> mpg123 $FILE
> done

I like to use xargs with find.  For simple cases, it seems cleaner
than the equivalent for loop.  If mpg123 can take more than one
filename on the command line, try:

	find / -name '*.mpg3' -print | xargs mpg123

If it only takes one, make that:

	find / -name '*.mpg3' -print | xargs -n 1 mpg123

And, finally, if you expect any of the filenames may contain
whitespace, try:

	find / -name '*.mpg3' -print0 | xargs -0 -n 1 mpg123



-Pat

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ML-3.3.909422530.3010.patl>