how to list recursive dirs only using ls

Dark Atheist

OSNN Veteran Addict
Political Access
Joined
8 Apr 2003
Messages
6,376
atm im trying

ls * >> list.txt but its only going 2 folders deep - i require 3 maybe 4 and just to list the dirs - not their content

using -R lists the files before anyone says - i did try that, and yes i have also done man ls :)
 

Dark Atheist

OSNN Veteran Addict
Political Access
Joined
8 Apr 2003
Messages
6,376
thanks lord, was looking at the tree option also, will try your suggestion out in a bit, if it works and if i can reps will be coming your way, if i cant you get a cookie :)
 

Geffy

OSNN Veteran Addict
Joined
18 Mar 2002
Messages
7,805
It varies from OS to OS but you sometimes need to include the -print option in find to have it print out the things it finds. Also if you have directories with spaces in them you can use -print0 to have find print a NULL byte at the end of each found item. This is mainly useful for teaming with "| xargs -0".
 

X-Istence

*
Political Access
Joined
5 Dec 2001
Messages
6,498
My solution is cooler than the find solution proposed above:

Code:
ls -Rl * | egrep -E "^d........" | rev | awk '{ print $1 }' | rev

However, that won't list full paths of the directories involved, and can cause duplicates.

Code:
ls -Rl / | grep ".*/.*:$" | sed "s/\:$//"

Lists just directories as found by ls.
 

Dark Atheist

OSNN Veteran Addict
Political Access
Joined
8 Apr 2003
Messages
6,376
thanks X - although i guess i should have put the dir i wanted to list n there instead of the / - as i only require one folder and its sub dirs not the whole filesystem :p
 

Members online

No members online now.

Latest profile posts

Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.
Terrahertz wrote on Electronic Punk's profile.
Yo fellas!
Electronic Punk wrote on Sazar's profile.
Where are you buddy?
Perris Calderon wrote on Electronic Punk's profile.
Hey EP! All good with me, applying for Microsoft MVP right now, should have done this a while ago.

Notifications don't work, I only found your response by coming back to hunt up some threads, if you want, give me your email address so we can keep in touch easier!
Perris Calderon wrote on Electronic Punk's profile.
EP, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there!

Forum statistics

Threads
61,997
Messages
673,411
Members
5,591
Latest member
nodee