I'm putting together a perl script, and I'm using the following command to list all files and directories under a specified directory

`find $dir -print`

This lists all files and directories UNDER directory $dir. I simply want something that will output files and directories directly under or IN directory $dir, using the find command.

link|improve this question
1  
Why do you want to use the find command? Why not just use Perl's built-in opendir and readdir functions? – Keith Thompson Oct 15 '11 at 4:41
@KeithThompson Too late now, it was written, it cannot be unwritten... – sj755 Oct 15 '11 at 4:52
1  
Perhaps I can recommend a few text editors with "delete" features. – Keith Thompson Oct 15 '11 at 4:54
@KeithThompson delete...never heard of it... – sj755 Oct 15 '11 at 6:17
feedback

1 Answer

up vote 2 down vote accepted

Pass -mindepth 1 -maxdepth 1 before any other predicates to restrict it to items located directly within the search directory.

link|improve this answer
WOW!!! That worked perfect thanks. – sj755 Oct 15 '11 at 4:51
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.