LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 10-19-2014, 12:27 AM   #1
Sumguy
Member
 
Registered: Jul 2010
Location: Rural Kentucky, USA.
Distribution: BunsenLabs Linux
Posts: 465
Blog Entries: 2

Rep: Reputation: 119Reputation: 119
What Does " */./* "mean?


So I figgered[sic] out how to run Mplayer from the terminal, and to specify that it play all files in all folders in a specified directory- now that I know HOW to do it, I want to know WHY it works.

I type this:

Code:
mplayer -shuffle ~/music/oldmusic/directorycontainingsubdirectories/*/./*.mp3
This enables me to shuffle all the files contained in the 66 subdirectories....

I don't understand what the
Code:
*/./*
means.

I know it's something simple- the * is like a wildcard that means "everything", right? What is the "." for? What exactly is */./* saying?

[Cool thing is, I made an alias, so I can just type one word, and BOOM! Mplayer starts playing the files mentioned above. Man, I LOVE Linux!]

Last edited by Sumguy; 10-19-2014 at 12:29 AM.
 
Old 10-19-2014, 01:11 AM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Quote:
Originally Posted by Sumguy View Post
So I figgered[sic] out how to run Mplayer from the terminal, and to specify that it play all files in all folders in a specified directory- now that I know HOW to do it, I want to know WHY it works.

I type this:

Code:
mplayer -shuffle ~/music/oldmusic/directorycontainingsubdirectories/*/./*.mp3
This enables me to shuffle all the files contained in the 66 subdirectories....

I don't understand what the
Code:
*/./*
means.
Unless mplayer has some esoteric path specifications, I would take that to mean...

Code:
~/music/oldmusic/directorycontainingsubdirectories/*/./*.mp3

all subdirectories and all mp3 files in those subdirectories.

which should be the same thing as...

~/music/oldmusic/directorycontainingsubdirectories/*/*.mp3
'./' simply means "this directory"

So I think that the './' is redundant. Try it without the './' in the path and see what happens.

Last edited by astrogeek; 10-19-2014 at 01:12 AM.
 
1 members found this post helpful.
Old 10-19-2014, 01:11 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Yes * is a glob to get all in a directory (not including hidden files).

. on its own is the current directory, just as .. is the directory above

in the context of */./*.mp3 I do not see a need for the ., so I believe you could have just written */*.mp3
 
1 members found this post helpful.
Old 10-19-2014, 02:15 AM   #4
Mr. Alex
Senior Member
 
Registered: May 2010
Distribution: No more Linux. Done with it.
Posts: 1,238

Rep: Reputation: Disabled
Code:
less ./././././././././././././././example.txt
will simply open "./example.txt", so the command above equals

Code:
less example.txt
 
1 members found this post helpful.
Old 10-19-2014, 08:24 AM   #5
Sumguy
Member
 
Registered: Jul 2010
Location: Rural Kentucky, USA.
Distribution: BunsenLabs Linux
Posts: 465

Original Poster
Blog Entries: 2

Rep: Reputation: 119Reputation: 119
You guys nailed it!

I tried it without the /./ and it worked just the same.
Code:
~/music/oldmusic/directorycontainingsubdirectories/*/*
I thought that might be the case....but the funny thing is, I got the

Code:
*/./*
from a reply to someone else's question on another forum, when I Googled for a way to play all subdirectories within a directory without having to make a playlist for Mplayer. It looked wrong to me, but I thought maybe i was just missing something, as I'm no 'puter geek!

And so, in like manner, if I were to do

Code:
mplayer -shuffle ~/music/*/*/*/*
It would play everything in ~/music?

Would it play everything at every "level"?

i.e. would it play both:

Code:
~/music/somecrappysong.mp3
AND
Code:
~/music/oldmusic/blahblahblah/crustyoldie.mp3
???

Thanks, everyone!

Last edited by Sumguy; 10-19-2014 at 08:28 AM. Reason: I effed-up!
 
Old 10-19-2014, 09:20 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
No ... it will only play all the files at the end of the chain, ie all those that exist in the directory after the last /
 
1 members found this post helpful.
Old 10-19-2014, 09:34 AM   #7
Sumguy
Member
 
Registered: Jul 2010
Location: Rural Kentucky, USA.
Distribution: BunsenLabs Linux
Posts: 465

Original Poster
Blog Entries: 2

Rep: Reputation: 119Reputation: 119
Quote:
Originally Posted by grail View Post
No ... it will only play all the files at the end of the chain, ie all those that exist in the directory after the last /
Ah, kinda what I suspected. Just for reference, would there be any way to specify a path which would allow it to play files contained at different levels?
 
Old 10-19-2014, 09:35 AM   #8
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
As grail said, the "/" forces it to only match directories. So if there are any files 2 levels down, they will be skipped and it will ONLY pass into directories, and those directories' subdirectories, and those subdirectories' files.

If you want to match any mp3 files at any level, you're better off using find.
Code:
find ~/music -iname "*.mp3"
I imagine you could then pass the list into mplayer with xargs
Code:
find ~/music -iname "*.mp3" | xargs mplayer -shuffle
 
1 members found this post helpful.
Old 10-19-2014, 10:16 AM   #9
Sumguy
Member
 
Registered: Jul 2010
Location: Rural Kentucky, USA.
Distribution: BunsenLabs Linux
Posts: 465

Original Poster
Blog Entries: 2

Rep: Reputation: 119Reputation: 119
Quote:
Originally Posted by suicidaleggroll View Post
As grail said, the "/" forces it to only match directories. So if there are any files 2 levels down, they will be skipped and it will ONLY pass into directories, and those directories' subdirectories, and those subdirectories' files.

If you want to match any mp3 files at any level, you're better off using find.
Code:
find ~/music -iname "*.mp3"
I imagine you could then pass the list into mplayer with xargs
Code:
find ~/music -iname "*.mp3" | xargs mplayer -shuffle
Interesting!

Just running the find command as youy specified, indeed finds all of the mp3's at any level under /music [This forum really needs a thumbs-up emoticon!]

But I suspect that piping it to mplayer requires a little more tweaking- trying it as specified, it had a few problems: It would attempt to play some files, but then say "file not found"[but it did play others]; the shuffle was not working; and when I'd hit enter to jump to the next track, it had no effect. Maybe a certain option has to be specified in mplayer?

This is VERY interesting, and very helpful- I have just learned a lot, that will be of great use to me as it pertains to many other scenarios! [Until now, I had never even heard of xargs!]

EDIT: Hmmm....maybe what we need here is something to just specify that the results of find be exported as a list to mplayer? [I'm clueless as to how to acheive that, but it should be easy for you guys!]

Last edited by Sumguy; 10-19-2014 at 10:29 AM.
 
Old 10-19-2014, 10:30 AM   #10
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,777

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
You will run into problems if any of the file or directory names include embedded whitespace characters. Each "word" will be passed as a separate argument, and mplayer won't be able to find a file by that name. A solution for that is to tell find and xargs to use the NUL character as a separator:
Code:
find ~/music -iname "*.mp3" -print0 | xargs -0 mplayer -shuffle
Or, simply let find invoke mplayer directly so that the names don't get re-parsed by xargs:
Code:
find ~/music -iname "*.mp3" -exec mplayer -shuffle {} +
 
1 members found this post helpful.
Old 10-19-2014, 10:50 AM   #11
Sumguy
Member
 
Registered: Jul 2010
Location: Rural Kentucky, USA.
Distribution: BunsenLabs Linux
Posts: 465

Original Poster
Blog Entries: 2

Rep: Reputation: 119Reputation: 119
Quote:
Originally Posted by rknichols View Post
You will run into problems if any of the file or directory names include embedded whitespace characters. Each "word" will be passed as a separate argument, and mplayer won't be able to find a file by that name. A solution for that is to tell find and xargs to use the NUL character as a separator:
Code:
find ~/music -iname "*.mp3" -print0 | xargs -0 mplayer -shuffle
Or, simply let find invoke mplayer directly so that the names don't get re-parsed by xargs:
Code:
find ~/music -iname "*.mp3" -exec mplayer -shuffle {} +
Ooooo! That seems to do it!

One question, for my edification: What does the "{} +" mean?
 
Old 10-19-2014, 11:09 AM   #12
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
"{}" means "stick the matching filename here".

There are two ways to end -exec in find:

1) "\;" - when you use this format, it will run the command once per matching file
2) "+" - when you use this format, it will run the command just one time, with all matching files
 
Old 10-19-2014, 12:51 PM   #13
Sumguy
Member
 
Registered: Jul 2010
Location: Rural Kentucky, USA.
Distribution: BunsenLabs Linux
Posts: 465

Original Poster
Blog Entries: 2

Rep: Reputation: 119Reputation: 119
Quote:
Originally Posted by suicidaleggroll View Post
"{}" means "stick the matching filename here".

There are two ways to end -exec in find:

1) "\;" - when you use this format, it will run the command once per matching file
2) "+" - when you use this format, it will run the command just one time, with all matching files
Thank you!!!

I'm intending to learn some basic scripting over the winter, as time permits, but so far, just what I've learned in this thread will help me do/simplify some other tasks.

Would the above apply to the "mv" command as well?

I mean, could I do this:

Code:
find `/<location> -iname "*.JPEG" -exec mv /<newlocation> *.jpg \
To move a file from one location to another, while changing it's .JPEG suffix to .jpg? Or maybe just pipe it, like:


Code:
find `/<location> -iname "*.JPEG" | mv /<newlocation> *.jpg \
(Sorry if I'm being a pain and an info glutton, but this is the best and fastest way for me to learn this stuff, as it is specific to what I need to do, and thus I will actually use it- and once I actually do it a few times, I'll remember it- unlike watching hours of youtube tutorials and then forgetting 99% of it after 15 minutes! )

EDIT: No, I know something is wrong there, regardless- as I somehow need to specify in the first part of mv where the file is coming from, not just the new location.....

Edit The 2nd: Ah-HA! Maybe:


Code:
find `/<location> -iname "*.JPEG" | mv {} /<newlocation> *.jpg \
Huh? HUH?!

Last edited by Sumguy; 10-19-2014 at 01:08 PM. Reason: [wags finger] No, no, no...
 
Old 10-19-2014, 01:25 PM   #14
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,777

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by Sumguy View Post
Edit The 2nd: Ah-HA! Maybe:


Code:
find `/<location> -iname "*.JPEG" -exec mv {} /<newlocation> *.jpg \
Close, but besides that stray back quote (that I assume is a typo) there are two problems. First, you don't want that final "*.jpg" on the mv command. It's getting its source arguments pasted in by find in place of the "{}" marker, and mv can't do name transformations like the rename command does. Second, you're missing the final semicolon. So, this would work:
Code:
find /<location> -iname "*.JPEG" -exec mv {} /<newlocation> \;
but if there is a large number of files it's inefficient because it invokes mv separately for each file. Trying to use "+" to move multiple files in one invocation runs into the problem that find insists on "{}" coming last in the argument list. The mv command has a "-t" (--target-directory) option to get around that as well:
Code:
find /<location> -iname "*.JPEG" -exec mv -t /<newlocation> {} +
To rename the ".JPEG" files to ".jpg", run the rename command separately:
Code:
rename .JPEG .jpg /<newlocation>/*.JPEG
 
1 members found this post helpful.
Old 10-19-2014, 11:18 PM   #15
Sumguy
Member
 
Registered: Jul 2010
Location: Rural Kentucky, USA.
Distribution: BunsenLabs Linux
Posts: 465

Original Poster
Blog Entries: 2

Rep: Reputation: 119Reputation: 119
Excellent! Thank you so much, rknichos! This is great info.

And thanks to all who have responded. I've learned far more than just the meaning of " */./* " !!!
 
  


Reply



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
What are the options "Nosuid" "mode" "size" in /etc/fstab? tuxfiles.org does not help pstein Linux - Newbie 1 11-16-2012 12:58 AM
unpredictable "delete" "move to trash" or "cut" file menu option dorianrenato Linux - General 3 11-28-2011 06:41 PM
net working eth0 eth1 wlan0 "no connection" "no LAN" "no wi-fi" Cayitano Linux - Newbie 5 12-09-2007 07:11 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:37 PM.

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
Open Source Consulting | Domain Registration