[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1759
  • Last Modified:

Solaris find command- ignore subdirectories

I am looking for a simple script to do some cleanup on directories older than n days.  As part of that script, I need to do a find on directories within my pwd.  However, I only want the top level directories returned, not subdirectories.

For instance, give the following:
ls
/mydir
/mydir/myotherdir/mythirddir
/yourdir
/yourdir/yourotherdir/yourthirddir
file.txt
file.sh

I only want my find command to return mydir and yourdir

Again, this is on solaris, so I don't have maxdepth.
0
krussell222
Asked:
krussell222
3 Solutions
 
ozoCommented:
do you have -prune
0
 
ozoCommented:
find .  ! -name . -prune
0
 
krussell222Author Commented:
yes
0
 
omarfaridCommented:
try

ls | while read line
do
   if [ -d $line ]
   then
        echo $line
   fi
done
0
 
TintinCommented:

ls -1F|grep /

Open in new window

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now