Linux commands - piping commands
Question
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?
Solution
May be play don't use STDIN so you have to use xargs
find ~/dir1 \*.m4a |xargs play
OTHER TIPS
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 ...
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
Use find -name *.mp4 -exec play {} /;
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