3

I tried the following command find ~/dir1 *.m4a | play

Directory dir1 has exactly 1 m4a file in it and I'd like it to be played Yet I get a usage error from play. Why?

1
  • Are you sure that play accepts files from its STDIN? Commented Jun 15, 2012 at 10:54

5 Answers 5

3

What you wrote instructs the output of the find command (an m4a file) to be send over as the input to the next command, play.

Now, I have no idea what that play exactly is, but most likely, it's syntax is of the type:

play filename

But what you wrote translates to:

play < "filename"

So, what you probably want to do is use a command like xargs, which will do exactly that:

find ~/dir1 *.m4a | xargs play

Which results in:

play foundfile1 foundfile2 ...
Sign up to request clarification or add additional context in comments.

Comments

2

May be play don't use STDIN so you have to use xargs

 find ~/dir1 \*.m4a |xargs play

1 Comment

You got lucky that the current directory didn't also contain a.m4a file, in which case your original answer would not work. You MUST escape shell metacharacters in patterns for find. I have updated your answer.
1

You are trying to pipe the contents of the file into play (i.e. sending it in via STDIN). As far as I can see from the play man page, it can't do this.

You want to send the filename that find to play, like this:

find ~/dir1 *.m4a | xargs play

Comments

1

Use find -name *.mp4 -exec play {} /;

Comments

-1

Try the other way:

play ~/dir1 *.m4a

If not working - check if play support m4a

or try with xargs in your pip line

xargs play

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.