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 :)
 
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 :)
 
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".
 
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.
 
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

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
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.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back