Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux commands - piping commands

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?

like image 446
user1413824 Avatar asked Jul 01 '26 00:07

user1413824


2 Answers

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 ...
like image 88
Miquel Avatar answered Jul 03 '26 13:07

Miquel


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

 find ~/dir1 \*.m4a |xargs play
like image 39
ob_dev Avatar answered Jul 03 '26 15:07

ob_dev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!