Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
2  
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
add comment

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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