Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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
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
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

Your Answer


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.