How to find directories

B

Bern

A newbie question:

I need to find all the subdirectories in a directory. I know how to
get the content of the directory but I don't know how I can identify
directories and for that matter any other kind of files under the same
directory.

I can I do that?

Thanks
Bern
 
P

Paul Lalli

A newbie question:

I need to find all the subdirectories in a directory. I know how to
get the content of the directory but I don't know how I can identify
directories and for that matter any other kind of files under the same
directory.

I can I do that?

To just determine whether a given directory entry is a file, directory,
link, etc, lookup:
perldoc -f -x

To recursively search directories, lookup:
perldoc File::Find

You'll want to use both of those to carry out your goal. Once you've read
them, if you have questions, let us know. Then make an attempt, and if it
doesn't work right, feel free to ask for help.

Paul Lalli
 
J

Jürgen Exner

Bern said:
I need to find all the subdirectories in a directory. I know how to
get the content of the directory but I don't know how I can identify
directories

perldoc -f -d

jue
 
M

Mladen Gogala

A newbie question:

I need to find all the subdirectories in a directory. I know how to
get the content of the directory but I don't know how I can identify
directories and for that matter any other kind of files under the same
directory.

I can I do that?

You use a trick:

find2perl $HOME -type d -print

That will produce the subroutine that you can use.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top