LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 01-23-2004, 09:42 PM   #1
day4night
LQ Newbie
 
Registered: Sep 2003
Location: Lancaster, PA
Distribution: Redhat 9
Posts: 2

Rep: Reputation: 0
ls command behavior


Hi,

How do I search for files more then one level below my current dir? For example by typing:

ls */*.mp3 I will see all mp3s one directory below my current dir. What I will not see is any mp3s more then one level below the current dir.

I've tried working the -R option (recurse dirs), but haven't been able to make it work. That is:

ls -R /*.mp3 or ls -R */*.mp3 or ls -R *.mp3 doesn't seem to work.

Any thoughts?

day4night
 
Old 01-23-2004, 10:04 PM   #2
looseCannon
Member
 
Registered: Dec 2003
Location: Little Rock, AR
Distribution: Fedora Core 2, AIX, HP-UX, Solaris, Whitebox
Posts: 193

Rep: Reputation: 31
Check the output again. This confused me at first, but it IS listing it recursively. The output doesn't include the full path in the name of the file. It's listing the path in the output just before the list of files in the directory that match your criteria.

In my home directory 'ls -R *mp3 gave back some output like:

mp3:
02 Your Wall.mp3
04 Seven.mp3
05 Goodbye Again.mp3

mp3/blue_october:
Blue October- Calling You.mp3 Blue October - Razorblade.mp3
Blue October - Inner Glow.mp3 Blue October - Ugly side.mp3
 
Old 01-23-2004, 11:00 PM   #3
pzatch
Member
 
Registered: Aug 2003
Location: Ohio
Posts: 173

Rep: Reputation: 30
try typing in

ls /
this gives you a root directory output.

ls /user/
gives a user directory output.

ls /home/

gives the /home directory output.
 
Old 01-24-2004, 06:55 AM   #4
day4night
LQ Newbie
 
Registered: Sep 2003
Location: Lancaster, PA
Distribution: Redhat 9
Posts: 2

Original Poster
Rep: Reputation: 0
thanks for the help. using 'ls -R *mp3' does what I wanted. I was using 'ls -R *.mp3' and it was not working. I guess the '.' was tripping it up. Oddly enough using a command like 'ls */*.mp3' doesn't mind the '.', but then again that command won't recurse through all subdirs.

day4night
 
Old 01-24-2004, 08:13 AM   #5
nightjar
Member
 
Registered: May 2002
Location: Argentina
Distribution: Mandrake 9.2
Posts: 177

Rep: Reputation: 30
You can type
ls --help
and watch the all options that the commmand have
 
Old 01-24-2004, 08:25 AM   #6
MrPotatoHead
Member
 
Registered: Mar 2003
Location: NY
Distribution: Fedora Core 1,RH AS 2.1, RH AS 3.0, Mandrake 9.0
Posts: 33

Rep: Reputation: 15
I think the find command will help you more in this.

If you want to find all mp3 lets say under /home you can use

find /home -name *.mp3

MrP
 
Old 01-24-2004, 11:56 PM   #7
thedong
LQ Newbie
 
Registered: Jan 2004
Posts: 1

Rep: Reputation: 0
i use the find cmd as well and then pipe it to grep, ie:
find . | grep mp3
 
Old 01-25-2004, 12:57 AM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Why not
find -iname *.mp3
?

Cheers,
Tink
 
  


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
Shutdown Behavior rhb327 Slackware 19 11-07-2004 09:39 PM
Unexpected Behavior (passwd command) Penguin666 Linux - General 3 11-19-2003 11:34 PM
ls -l behavior vjl323 Mandriva 3 11-05-2003 07:30 AM
Strange Behavior andrewb758 Linux - Hardware 5 08-31-2003 02:42 PM
disgraceful behavior gui10 General 7 04-23-2002 08:46 PM

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

All times are GMT -5. The time now is 03:44 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