LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-22-2010, 03:34 PM   #1
mukami
LQ Newbie
 
Registered: May 2009
Location: Riyadh
Distribution: Fedora 10
Posts: 7

Rep: Reputation: 0
reusing find command results in mplayer arguments


I wanted to supply mplayer with the output of find command as arguments. The error returned showed spliced names of files whenever spaces occurred. I have subdirectories in my /home/my_user_name/Music/ directory, and in them multiple *.oga music files. The actual command that I issued was
Code:
mplayer $(find /home/my_user_name/Music/ -name "*.oga")
mplayer started but then was looking for broken file names. I am thinking quoting has to do with it to preserve the filename as one string but different attempts were met with inroads:
Code:
mplayer `find /home/my_user_name/Music/ -name "*.oga"`
gave me the same result and
Code:
mplayer `"find /home/my_user_name/Music/ -name *.oga"`
complained about wrong mplayer syntax. Thanks in advance for your consideration.
 
Old 01-22-2010, 04:11 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Here is some suggestions:

1) use the -exec action of the find command to run mplayer. This will start a new process for each audio file, anyway:
Code:
find /home/my_user_name/Music/ -name "*.oga" -exec mplayer {} \;
2) use a while read loop, feeding it using process substitution. This is my favorite method to loop over files containing spaces in their name:
Code:
while read file
do
  mplayer "$file"
done < <(find /home/my_user_name/Music/ -name "*.oga")
3) create a simple one-file-per-line playlist and play it using the -playlist option of mplayer. This will run a single mplayer session:
Code:
find /home/my_user_name/Music/ -name "*.oga" > ./my_music_list
mplayer -playlist ./my_music_list
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Grab results of GRUB's find command into a shell script variable kushalkoolwal Programming 6 02-03-2009 05:04 PM
find command displays unexpected results helptonewbie Linux - Newbie 5 08-12-2008 02:25 AM
command line arguments nickraj Programming 6 09-11-2006 01:01 PM
command arguments in perl djgerbavore Programming 1 12-30-2004 08:06 AM
see what arguments are available for a command naijaguy Linux - Newbie 3 08-12-2004 10:05 PM


All times are GMT -5. The time now is 12:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration