How to display directories recursively?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to display directories recursively?
# 1  
Old 04-21-2007
How to display directories recursively?

Cannot find how to list the directory structure of a volume recursively. Do not want the files reported. Say I have 100 directories and 10,000 files, I do not want 10,000 lines of output. (If this is relevant, I am using the terminal on my OSX Mac). I hope this is easy - there should be an easy way. -- jim
# 2  
Old 04-21-2007
Code:
find <base directory> -type d

eg:

Code:
find /export -type d

# 3  
Old 04-21-2007
Thank you Reborg. Since this is a dummies group, could you explain why number (1) works but numbers (2) and (3) don't work?

(1)
guests-Computer:/volumes/white guest$ pwd
/volumes/white
guests-Computer:/volumes/white guest$ find . -type d
.
./pho_pp
./pho_pp/Test_dir
./pho_pers
(snip)

(2)
guests-Computer:/volumes/white guest$ pwd
/volumes/white
guests-Computer:/volumes/white guest$ find /white -type d
find: /white: No such file or directory

(3)
guests-Computer:/volumes guest$ pwd
/volumes
guests-Computer:/volumes guest$ find /white -type d
find: /white: No such file or directory
# 4  
Old 04-22-2007
In (1), you specify that the find command is to search in the pwd. In (2) and (3), the find command is supposed to search in the /white directory which does not exist. In fact, it clearly says that in the output doesn't it.

To make (3) work, run the command as:
Code:
guests-Computer:/volumes guest$ pwd
/volumes
guests-Computer:/volumes guest$ find white -type d

Assuming that 'white' is a directory inside /volumes, the command will work.
# 5  
Old 04-23-2007
One of the easy way to list just the directory is using ls -ltr|grep ^d
try that.
# 6  
Old 04-23-2007
Easy yes, but incredibly slow, and in most cases not very useful output for use in a script.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generic script to recursively cd into directories and git pull

Hi all, I'm trying to write a script to recursively cd into my Git projects and pull them, and will later expand it to build my projects as well. I'm having a bit of trouble with my current script, as I want to supply a command line argument to tell it which branch to check out. I can hard... (2 Replies)
Discussion started by: Cows
2 Replies

2. Shell Programming and Scripting

Recursively Searcing file in the directories

i have directory dgf in the dgf( some other Sub-dir are there) 00 01 02 03 04 in all the Sub directory there is a SG.csv .. i want the scripts should run one by one Sub-dir and print the result for that particular Sub-dir ..then go to next Sub-Dir and print the result....... please... (6 Replies)
Discussion started by: Aditya.Gurgaon
6 Replies

3. Shell Programming and Scripting

Shell script to copy particular file from directories recursively

I have directory path in which there are several sub directories. In all these sub dir there will be one env.cnf file. I want to copy this env.cnf file from each sub dir's and place them in destination path by creating same filename as sub dir_env.cnf. After copying env.cnf files from source... (4 Replies)
Discussion started by: Optimus81
4 Replies

4. Solaris

Display the number of files in a directory and recursively in each subdirectory

Display the number of files in a directory and recursively in each subdirectory To look something like below, for example /var 35 /var/tmp 56 /var/adm 46Any ideas how can we do this? Got a sun cluser global mount point which takes ages to mount everytime, need to understand... (5 Replies)
Discussion started by: jakerock
5 Replies

5. Shell Programming and Scripting

Recursively rename directories

I have this directory tree under /apps/myapp/data: imageshack.us/photo/my-images/703/foldersc.png How to recursively rename ONLY directories with 5 digits (00000, 00100, 00200,..., 00007, 00107,...)? I want to add to their name two more zeros: Before: 00107 After: 0000107 Thanks in... (2 Replies)
Discussion started by: Susan_45
2 Replies

6. UNIX for Advanced & Expert Users

Delete empty directories recursively - HP-UX

Hi, I want to delete all empty directories in a long directore tree structure. I want to use that from a script that will run on HP-UX 11. My definition of empty directory is that there is no regular file under it and directly beneath it. To elaborate, I have below directories. /app/dev/java... (14 Replies)
Discussion started by: asutoshch
14 Replies

7. UNIX for Dummies Questions & Answers

List directories and sub directories recursively excluding files

Hi, Please help me, how to get all the direcotries, its sub directories and its sub directories recursively, need to exclude all the files in the process. I wanted to disply using a unix command all the directories recursively excluding files. I tried 'ls -FR' but that display files as... (3 Replies)
Discussion started by: pointers
3 Replies

8. UNIX for Advanced & Expert Users

Recursively delete only specified directories with given pattern

Hi All, We have a requirement to recursively delete the directories and its subdirectories older than 60 days based on timestamp (folder creation timestamp)under certain directory. However it has some specific requirements. The directories will continue to be there upto any depth. the... (0 Replies)
Discussion started by: rcvasu
0 Replies

9. UNIX for Dummies Questions & Answers

Recursively deleting directories

Say I have a directory call test, and several directories nested in it, and several directories nested in them. And I want to remove all directories within "test" and its subdirectories that have the name "cvs", how can I do this? I tried rm -r cvs, but that only removed the top level direcotry... (4 Replies)
Discussion started by: mikeshank
4 Replies
Login or Register to Ask a Question